Skip to content

Commit

Permalink
fix incorrect state value (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmenglund authored Nov 6, 2023
1 parent 2630ada commit 24abe4e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions option/query_lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ type QueryLambdaState string
func (q QueryLambdaState) String() string { return string(q) }

const (
QueryLambdaActive QueryLambdaState = "ACTIVE"
QueryLambdaInvalid QueryLambdaState = "INVALID"
QueryLambdaActive QueryLambdaState = "ACTIVE"
QueryLambdaInvalidSQL QueryLambdaState = "INVALID_SQL"
)

type ExecuteQueryLambdaRequest struct {
Expand Down
2 changes: 1 addition & 1 deletion wait/query_lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (w *Waiter) UntilQueryLambdaVersionGone(ctx context.Context, workspace, nam
func (w *Waiter) UntilQueryLambdaVersionActive(ctx context.Context, workspace, name, version string) error {
return w.rc.RetryWithCheck(ctx,
ResourceHasState(ctx,
[]option.QueryLambdaState{option.QueryLambdaActive}, []option.QueryLambdaState{option.QueryLambdaInvalid},
[]option.QueryLambdaState{option.QueryLambdaActive}, []option.QueryLambdaState{option.QueryLambdaInvalidSQL},
func(ctx context.Context) (option.QueryLambdaState, error) {
ql, err := w.rc.GetQueryLambdaVersion(ctx, workspace, name, version)
return option.QueryLambdaState(ql.GetState()), err
Expand Down
6 changes: 4 additions & 2 deletions wait/query_lambda_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ func TestWait_untilQueryLambdaActive(t *testing.T) {

rs := fakeRocksetClient()
rs.GetQueryLambdaVersionReturnsOnCall(0, openapi.QueryLambdaVersion{State: &emptyString}, nil)
rs.GetQueryLambdaVersionReturnsOnCall(1, openapi.QueryLambdaVersion{State: stringPtr(option.QueryLambdaActive)}, nil)
rs.GetQueryLambdaVersionReturnsOnCall(1, openapi.QueryLambdaVersion{
State: stringPtr(option.QueryLambdaActive)}, nil)

err := wait.New(&rs).UntilQueryLambdaVersionActive(ctx, "ws", "ql", "v")
assert.NoError(t, err)
Expand All @@ -29,7 +30,8 @@ func TestWait_untilQueryLambdaActive_invalid(t *testing.T) {

rs := fakeRocksetClient()
rs.GetQueryLambdaVersionReturnsOnCall(0, openapi.QueryLambdaVersion{State: &emptyString}, nil)
rs.GetQueryLambdaVersionReturnsOnCall(1, openapi.QueryLambdaVersion{State: stringPtr(option.QueryLambdaInvalid)}, nil)
rs.GetQueryLambdaVersionReturnsOnCall(1, openapi.QueryLambdaVersion{
State: stringPtr(option.QueryLambdaInvalidSQL)}, nil)

err := wait.New(&rs).UntilQueryLambdaVersionActive(ctx, "ws", "ql", "v")
assert.ErrorIs(t, err, rockerr.ErrBadWaitState)
Expand Down

0 comments on commit 24abe4e

Please sign in to comment.