package instance import ( "context" "strings" "testing" "time" "git.yuntuo.hk/k2safe/orbit/platform/auth" ) func TestListBoundary(t *testing.T) { store := &captureStore{} api := New(store) if _, err := api.List(context.Background(), auth.Token{}, ListInput{}); err != nil { t.Fatal(err) } now := time.Now().UTC().Truncate(time.Microsecond) for _, in := range []ListInput{{Limit: -1}, {Limit: 101}, {Cursor: strings.Repeat("x", 1025)}, {DefinitionID: "bad"}, {Version: "v1"}, {DefinitionID: "11111111111111111111111111111111", Version: "../v1"}, {State: "STOPPED"}, {BusinessKey: "\xff"}, {BusinessKey: "nul\x00"}, {BusinessKey: strings.Repeat("δΈ­", 192)}, {CreatedFrom: &now, CreatedBefore: &now}} { if _, err := api.List(context.Background(), auth.Token{}, in); err == nil { t.Fatal("invalid query accepted", in) } } if store.calls != 1 { t.Fatal("invalid query reached store") } }