diff --git a/predict/options_test.go b/predict/options_test.go new file mode 100644 index 0000000..dc6d83d --- /dev/null +++ b/predict/options_test.go @@ -0,0 +1,39 @@ +package predict + +import "testing" + +import "github.com/stretchr/testify/assert" + +func TestConfigCheck(t *testing.T) { + t.Parallel() + + t.Run("enabled", func(t *testing.T) { + cfg := Options(OptValues("foo", "bar", "foo-bar"), OptCheck()) + assert.NoError(t, cfg.Check("foo")) + assert.NoError(t, cfg.Check("bar")) + assert.NoError(t, cfg.Check("foo-bar")) + assert.Error(t, cfg.Check("fo")) + assert.Error(t, cfg.Check("baz")) + }) + + t.Run("disabled", func(t *testing.T) { + cfg := Options(OptValues("foo", "bar", "foo-bar")) + assert.NoError(t, cfg.Check("foo")) + assert.NoError(t, cfg.Check("fo")) + assert.NoError(t, cfg.Check("baz")) + }) +} + +func TestConfigPredict(t *testing.T) { + t.Parallel() + + t.Run("set", func(t *testing.T) { + cfg := Options(OptValues("foo", "bar", "foo-bar")) + assert.Equal(t, []string{"foo", "bar", "foo-bar"}, cfg.Predict("")) + }) + + t.Run("not set", func(t *testing.T) { + cfg := Options() + assert.Nil(t, cfg.Predict("")) + }) +}