-
Notifications
You must be signed in to change notification settings - Fork 270
Snippet and tests syncing #3925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
) | ||
|
||
var ( | ||
testsCmd = &cobra.Command{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have a test
root command that we can enrich https://github.com/supabase/cli/blob/develop/cmd/test.go
"favorite": false, | ||
"schema_version": schemaVersion, | ||
"sql": sql, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix the openapi type so this can be a properly generated struct.
I'd also use multipart/form upload for sql snippets to avoid string escape issues when converting sql function to json.
|
||
const ( | ||
ContentTypeTest ContentType = "test" | ||
ContentTypeSnippet ContentType = "snippet" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can reuse the generated enums for api.UpsertContentBodyType
to simplify type conversion
Visibility: api.UpsertContentBodyVisibilityProject, | ||
Content: &content, | ||
} | ||
resp, err := utils.GetSupabase().V1ProjectUpsertSnippetWithResponse(ctx, flags.ProjectRef, id, body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
upsert really means update or insert. The operation id for this openapi spec should be v1-project-update-snippet
for clarity
if !isCorrectType(s.Type, contentType) || s.Visibility != api.SnippetListDataVisibilityProject { | ||
continue | ||
} | ||
id, err := uuid.Parse(s.Id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update openapi response type to uuid to avoid this client side conversion loop
return nil | ||
} | ||
|
||
func DownloadAll(ctx context.Context, fsys afero.Fs, contentType ContentType) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest breaking this up
ListSnippets(ctx context.Context, contentType ContentType)
DownloadSnippets(ctx context.Context, snippetIds []uuid.UUID, fsys afero.Fs)
There's no need to have a separate DownloadOne since we can use a single element array.
This adds commands for downloading and pushing "snippets" to remote (dashboard). As part of database testing work, a snippet can either by "sql" (e.g. in sql editor) or "tests". A test is an sql file that makes use of pgTap. https://supabase.com/docs/guides/database/testing
tests download
downloads project snippets of type test to thetests/database
folder.snippets download
downloads project snippets of type sql to the snippets folder.Infrastructure PR https://github.com/supabase/infrastructure/pull/24519
Studio PR supabase/supabase#37499