コード例 #1
0
ファイル: conn_test.go プロジェクト: postfix/name_pending
func waitConnAndClose(t *testing.T) {
	done := make(chan struct{})
	quit := make(chan struct{})
	go func() {
		<-ircd.conn
		quit <- struct{}{}
		<-ircd.connClosed
		close(done)
	}()

	for {
		select {
		case <-done:
			return

		case <-quit:
			assert.True(t, c.Connected())
			c.Quit()

		case <-time.After(500 * time.Millisecond):
			t.Error("Took too long")
			return
		}
	}
}
コード例 #2
0
ファイル: viper_test.go プロジェクト: postfix/name_pending
func TestMarshalling(t *testing.T) {
	SetConfigType("yaml")
	r := bytes.NewReader(yamlExample)

	marshalReader(r, v.config)
	assert.True(t, InConfig("name"))
	assert.False(t, InConfig("state"))
	assert.Equal(t, "steve", Get("name"))
	assert.Equal(t, []interface{}{"skateboarding", "snowboarding", "go"}, Get("hobbies"))
	assert.Equal(t, map[interface{}]interface{}{"jacket": "leather", "trousers": "denim"}, Get("clothing"))
	assert.Equal(t, 35, Get("age"))
}
コード例 #3
0
ファイル: viper_test.go プロジェクト: postfix/name_pending
func TestReadBufConfig(t *testing.T) {
	v := New()
	v.SetConfigType("yaml")
	v.ReadConfig(bytes.NewBuffer(yamlExample))
	t.Log(v.AllKeys())

	assert.True(t, v.InConfig("name"))
	assert.False(t, v.InConfig("state"))
	assert.Equal(t, "steve", v.Get("name"))
	assert.Equal(t, []interface{}{"skateboarding", "snowboarding", "go"}, v.Get("hobbies"))
	assert.Equal(t, map[interface{}]interface{}{"jacket": "leather", "trousers": "denim"}, v.Get("clothing"))
	assert.Equal(t, 35, v.Get("age"))
}