-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): hatchery config property IgnoreJobWithNoRegion on consumer (…
- Loading branch information
Showing
22 changed files
with
219 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package gorpmapper | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/ovh/cds/sdk" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type testService struct { | ||
sdk.Service | ||
SignedEntity | ||
} | ||
|
||
func (s testService) Canonical() CanonicalForms { | ||
return []CanonicalForm{ | ||
"{{.ID}}{{.Name}}{{.Type}}{{.Region}}{{.IgnoreJobWithNoRegion}}", | ||
} | ||
} | ||
|
||
func Test_CanonicalFormWithPointer(t *testing.T) { | ||
m := New() | ||
m.Register(m.NewTableMapping(testService{}, "service", false, "id")) | ||
|
||
region := "test" | ||
|
||
cases := []struct { | ||
name string | ||
s testService | ||
res string | ||
}{ | ||
{ | ||
name: "Service with empty values", | ||
s: testService{ | ||
Service: sdk.Service{ | ||
CanonicalService: sdk.CanonicalService{ | ||
ID: 123, | ||
Name: "my-service", | ||
Type: sdk.TypeHatchery, | ||
Region: nil, | ||
IgnoreJobWithNoRegion: nil, | ||
}, | ||
}, | ||
}, | ||
res: "123my-servicehatchery<nil><nil>", | ||
}, | ||
{ | ||
name: "Service without empty values", | ||
s: testService{ | ||
Service: sdk.Service{ | ||
CanonicalService: sdk.CanonicalService{ | ||
ID: 123, | ||
Name: "my-service", | ||
Type: sdk.TypeHatchery, | ||
Region: ®ion, | ||
IgnoreJobWithNoRegion: &sdk.True, | ||
}, | ||
}, | ||
}, | ||
res: "123my-servicehatcherytesttrue", | ||
}, | ||
} | ||
|
||
for _, c := range cases { | ||
t.Run(c.name, func(t *testing.T) { | ||
f, _ := c.s.Canonical().Latest() | ||
tmpl, err := m.getCanonicalTemplate(f) | ||
require.NoError(t, err) | ||
require.NotNil(t, tmpl) | ||
|
||
var clearContent = new(bytes.Buffer) | ||
require.NoError(t, tmpl.Execute(clearContent, c.s)) | ||
|
||
require.Equal(t, c.res, clearContent.String()) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- +migrate Up | ||
ALTER TABLE "auth_consumer" ADD COLUMN IF NOT EXISTS "service_ignore_job_with_no_region" BOOLEAN; | ||
|
||
ALTER TABLE "service" ADD COLUMN IF NOT EXISTS "ignore_job_with_no_region" BOOLEAN; | ||
|
||
-- +migrate Down | ||
ALTER TABLE "auth_consumer" DROP COLUMN IF EXISTS "service_ignore_job_with_no_region"; | ||
|
||
ALTER TABLE "service" DROP COLUMN IF EXISTS "ignore_job_with_no_region"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.