// TestFlagTimeout tests the waiting for a signal with // a timeout. func TestFlagTimeout(t *testing.T) { assert := asserts.NewTestingAssertion(t, false) scn := scene.Start() go func() { err := scn.WaitFlag("foo") assert.Nil(err) err = scn.Store("foo-a", true) assert.Nil(err) }() go func() { err := scn.WaitFlagLimited("foo", 50*time.Millisecond) assert.True(scene.IsWaitedTooLongError(err)) err = scn.Store("foo-b", true) assert.Nil(err) }() time.Sleep(100 * time.Millisecond) err := scn.Flag("foo") assert.Nil(err) fooA, err := scn.Fetch("foo-a") assert.Nil(err) assert.Equal(fooA, true) fooB, err := scn.Fetch("foo-b") assert.Nil(err) assert.Equal(fooB, true) err = scn.Stop() assert.Nil(err) }
// TestFlagUnflag tests the removal of a flag. func TestFlagUnflag(t *testing.T) { assert := asserts.NewTestingAssertion(t, false) scn := scene.Start() err := scn.Flag("foo") assert.Nil(err) err = scn.Unflag("foo") assert.Nil(err) err = scn.WaitFlagLimited("foo", 50*time.Millisecond) assert.True(scene.IsWaitedTooLongError(err)) err = scn.Stop() assert.Nil(err) }