Example #1
0
// 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)
}
Example #2
0
// 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)
}