Skip to content

Commit dad4a5c

Browse files
update test
1 parent ca24d8a commit dad4a5c

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

internal/services/services_test.go

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestRun(t *testing.T) {
3232
fsys := afero.NewMemMapFs()
3333

3434
// Create project config file with project reference
35-
projectRef := "test-project-ref"
35+
projectRef := "abcdefghijklmnopqrst"
3636
require.NoError(t, utils.InitConfig(utils.InitParams{
3737
ProjectId: projectRef,
3838
}, fsys))
@@ -72,7 +72,7 @@ func TestCheckVersions(t *testing.T) {
7272
fsys := afero.NewMemMapFs()
7373

7474
// Create project config file with project reference
75-
projectRef := "test-project-ref"
75+
projectRef := "abcdefghijklmnopqrst"
7676
require.NoError(t, utils.InitConfig(utils.InitParams{
7777
ProjectId: projectRef,
7878
}, fsys))
@@ -98,7 +98,7 @@ func TestCheckVersions(t *testing.T) {
9898
fsys := afero.NewMemMapFs()
9999

100100
// Create project config file with project reference
101-
projectRef := "test-project-ref"
101+
projectRef := "abcdefghijklmnopqrst"
102102
require.NoError(t, utils.InitConfig(utils.InitParams{
103103
ProjectId: projectRef,
104104
}, fsys))
@@ -121,7 +121,7 @@ func TestCheckVersions(t *testing.T) {
121121
// Test case: Verify version comparison logic
122122
t.Run("compares local and remote versions correctly", func(t *testing.T) {
123123
fsys := afero.NewMemMapFs()
124-
projectRef := "test-project-ref"
124+
projectRef := "abcdefghijklmnopqrst"
125125

126126
// Setup: Create linked project with specific versions
127127
require.NoError(t, utils.InitConfig(utils.InitParams{
@@ -162,7 +162,7 @@ func TestListRemoteImages(t *testing.T) {
162162
t.Run("gets remote versions successfully", func(t *testing.T) {
163163
// Setup: Create context and project reference
164164
ctx := context.Background()
165-
projectRef := "test-project-ref"
165+
projectRef := "abcdefghijklmnopqrst"
166166

167167
// Setup: Create in-memory filesystem
168168
fsys := afero.NewMemMapFs()
@@ -182,23 +182,33 @@ func TestListRemoteImages(t *testing.T) {
182182
{"name": "anon", "api_key": "test-key"},
183183
})
184184

185-
// Mock database version response
186185
gock.New(utils.DefaultApiHost).
187-
Get("/v1/projects/" + projectRef + "/database/version").
186+
Get("/v1/projects").
188187
Reply(200).
189-
JSON(map[string]string{"version": "1.0.0"})
188+
JSON([]map[string]interface{}{
189+
{
190+
"id": projectRef,
191+
"database": map[string]string{
192+
"version": "1.0.0",
193+
},
194+
},
195+
})
190196

191-
// Mock auth version response
192-
gock.New(utils.DefaultApiHost).
193-
Get("/auth/v1/version").
197+
gock.New("https://" + utils.GetSupabaseHost(projectRef)).
198+
Get("/auth/v1/health").
194199
Reply(200).
195200
JSON(map[string]string{"version": "2.0.0"})
196201

197-
// Mock postgrest version response
198-
gock.New(utils.DefaultApiHost).
199-
Get("/rest/v1/version").
202+
// Mock postgrest version response (endpoint = /rest/v1/ sur le host du projet)
203+
gock.New("https://" + utils.GetSupabaseHost(projectRef)).
204+
Get("/rest/v1/").
200205
Reply(200).
201-
JSON(map[string]string{"version": "3.0.0"})
206+
JSON(map[string]interface{}{
207+
"swagger": "2.0",
208+
"info": map[string]string{
209+
"version": "3.0.0",
210+
},
211+
})
202212

203213
// Execute: Call listRemoteImages function
204214
remoteVersions := listRemoteImages(ctx, projectRef)
@@ -243,7 +253,7 @@ func TestListRemoteImages(t *testing.T) {
243253
t.Run("handles missing access token", func(t *testing.T) {
244254
// Setup: Create context and project reference
245255
ctx := context.Background()
246-
projectRef := "test-project-ref"
256+
projectRef := "abcdefghijklmnopqrst"
247257

248258
// Setup: Create in-memory filesystem without access token
249259
afero.NewMemMapFs()

0 commit comments

Comments
 (0)