示例#1
0
文件: client_test.go 项目: vsco/dcdr
func TestSet(t *testing.T) {
	ft := models.NewFeature("test", 0.5, "c", "u", "s", "n")
	cs := stores.NewMockStore(ft, nil)
	c := New(cs, &stores.MockRepo{}, config.DefaultConfig(), nil)

	err := c.Set(ft)

	assert.Nil(t, err)
}
示例#2
0
文件: client_test.go 项目: vsco/dcdr
func TestSetErrorOnNilValue(t *testing.T) {
	ft := models.NewFeature("test", nil, "c", "u", "s", "n")
	cs := stores.NewMockStore(nil, nil)
	c := New(cs, &stores.MockRepo{}, config.DefaultConfig(), nil)

	err := c.Set(ft)

	assert.Equal(t, ErrNilValue, err)
}
示例#3
0
文件: client_test.go 项目: vsco/dcdr
func TestSetWithError(t *testing.T) {
	ft := models.NewFeature("test", 0.5, "c", "u", "s", "n")
	e := errors.New("")
	cs := stores.NewMockStore(ft, e)
	c := New(cs, nil, config.DefaultConfig(), nil)

	err := c.Set(ft)

	assert.Equal(t, e, err)
}
示例#4
0
文件: client_test.go 项目: vsco/dcdr
func TestTypeChangeErrorSet(t *testing.T) {
	orig := models.NewFeature("test", 0.5, "c", "u", "s", "n")
	bad := models.NewFeature("test", false, "c", "u", "s", "n")

	cs := stores.NewMockStore(orig, nil)
	c := New(cs, nil, config.DefaultConfig(), nil)

	err := c.Set(bad)
	assert.Equal(t, ErrTypeChange, err)
}
示例#5
0
文件: client_test.go 项目: vsco/dcdr
func TestNilGet(t *testing.T) {
	cs := stores.NewMockStore(nil, nil)
	c := New(cs, &stores.MockRepo{}, config.DefaultConfig(), nil)

	var f *models.Feature
	err := c.Get("test", &f)

	assert.EqualError(t, err, "dcdr/test not found")
	assert.Nil(t, f)
}
示例#6
0
文件: client_test.go 项目: vsco/dcdr
func TestList(t *testing.T) {
	ft := models.NewFeature("test", 0.5, "c", "u", "s", "n")
	cs := stores.NewMockStore(ft, nil)
	c := New(cs, &stores.MockRepo{}, config.DefaultConfig(), nil)

	fts, err := c.List("test", "")

	assert.Nil(t, err)
	assert.Equal(t, models.Features{*ft}, fts)
}
示例#7
0
文件: client_test.go 项目: vsco/dcdr
func TestClientSetExisting(t *testing.T) {
	update := models.NewFeature("test", nil, "c", "u", "s", "n")
	orig := models.NewFeature("test", 0.5, "c", "u", "s", "n")

	c := New(stores.NewMockStore(orig, nil), &stores.MockRepo{}, config.DefaultConfig(), nil)

	err := c.Set(update)

	assert.NoError(t, err)
}
示例#8
0
文件: client_test.go 项目: vsco/dcdr
func TestDeleteWithError(t *testing.T) {
	ft := models.NewFeature("test", 0.5, "c", "u", "s", "n")
	e := errors.New("")
	cs := stores.NewMockStore(ft, e)
	c := New(cs, &stores.MockRepo{}, config.DefaultConfig(), nil)

	err := c.Delete(ft.Key, "")

	assert.Equal(t, e, err)
}
示例#9
0
文件: client_test.go 项目: vsco/dcdr
func TestGet(t *testing.T) {
	ft := models.NewFeature("test", 0.5, "c", "u", "s", "n")
	cs := stores.NewMockStore(ft, nil)
	c := New(cs, &stores.MockRepo{}, config.DefaultConfig(), nil)

	var f *models.Feature
	err := c.Get("test", &f)

	assert.Nil(t, err)
	assert.Equal(t, f, ft)
}