示例#1
0
文件: client.go 项目: vsco/dcdr
// UpdateFeatures creates and assigns a new `FeatureMap` from a
// Marshalled JSON byte array
func (c *Client) UpdateFeatures(bts []byte) {
	fm, err := models.NewFeatureMap(bts)

	if err != nil {
		printer.SayErr("parse error: %v", err)
		return
	}

	c.SetFeatureMap(fm)
}
示例#2
0
文件: client_test.go 项目: vsco/dcdr
func TestWatch(t *testing.T) {
	p := "/tmp/decider.json"
	fm, err := models.NewFeatureMap(JSONBytes)
	assert.NoError(t, err)
	err = ioutil.WriteFile(p, JSONBytes, 0644)
	assert.NoError(t, err)

	cfg := config.DefaultConfig()
	cfg.Watcher.OutputPath = p
	c, err := New(cfg)
	if err != nil {
		assert.NoError(t, err)
	}
	c.Watch()

	assert.Equal(t, fm, c.FeatureMap())

	err = os.Remove(p)
	assert.NoError(t, err)
}