// 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) }
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) }