Make terminal UI shutdown idempotent
This commit is contained in:
committed by
Brandon McGinty
parent
41759b95f6
commit
5bf3ed8b84
@@ -0,0 +1,16 @@
|
||||
package uiterm
|
||||
|
||||
import "testing"
|
||||
|
||||
// Regression: Close sent to a bounded channel and could block or enqueue
|
||||
// duplicate shutdowns when called more than once.
|
||||
func TestCloseIsNonblockingAndIdempotent(t *testing.T) {
|
||||
ui := New(nil)
|
||||
ui.Close()
|
||||
ui.Close()
|
||||
select {
|
||||
case <-ui.close:
|
||||
default:
|
||||
t.Fatal("Close did not signal shutdown")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user