Skip to content

Commit

Permalink
fix: reversed names of tests (public and private) + DRY common consts
Browse files Browse the repository at this point in the history
  • Loading branch information
francardoso93 committed Oct 27, 2023
1 parent 30e245b commit 57923f4
Showing 1 changed file with 23 additions and 32 deletions.
55 changes: 23 additions & 32 deletions src/services/k8s/knative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,31 @@ import (
)

const (
root = "../../../"
caCrt = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUNsakNDQVg0Q0NRRCtnL1BXUWJDSEFUQU5CZ2txaGtpRzl3MEJBUXNGQURBTk1Rc3dDUVlEVlFRR0V3SlYKVXpBZUZ3MHlNekExTURreE9EUTNNakZhRncweU5EQTFNRGd4T0RRM01qRmFNQTB4Q3pBSkJnTlZCQVlUQWxWVApNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQTMzZXhaMldSUGtGeTJiQTQ4Z3RvClVwK0JkMFd2THFROU50WDBOS014YnA1SjEwMS9VaTVsY1RIcllDMWRqYTVwdjFKVGNGUW1jcWpBajBpL3dBakMKRm5oL1JKbVFrMHE1Y2liZWNURnA5UUFvRVNmbzJxYXovUTFmbmk4OG9ONlk1b1VGd2hrdTJ1bzNUWnV6M0JDMApNRnRyNXRDSGh1UzFObFhVT05VcHpzbW1UZzdZL0R1QXpNK3VIZS9qZlo1eHFqQUx3WHV6SkRFNkNCUGdhbHh6Ck9QM0V4QWNaMmRDWnRCREpVUnpTL29qMFYxOVdsRG5FK1FkTmtGTXlaMHN1UGxPTy95V0Ercno1byt2c2dKVGgKa2ZjaVZQSXZBOUdJdDdOcDZVdzU3MW1VOVlmd2x6MlU0Qm1xTXl6M05pZFF3bVd3V0wvay8yRHlXa0JDaFRBKwpvd0lEQVFBQk1BMEdDU3FHU0liM0RRRUJDd1VBQTRJQkFRQWQ2M01qbFRJSWlSaVdOSDZvcDJySURjY1d5aWNKClJGbHJoODllSDVWeU04Q1o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"93f4be93"
)

var (
envSampleFile = path.Join(root, "example/.env.initium.sample")
secretRefEnvSampleFile = path.Join(root, "example/.env.secretref.initium.sample")
proj = &project.Project{Name: "knative_test",
Directory: path.Join(root, "example"),
Resources: os.DirFS(root),
IsPrivate: false,
}
dockerImage = docker.DockerImage{
Registry: "example.com",
Directory: ".",
Name: "test",
Tag: "v1.1.0",
}
)

func TestConfig(t *testing.T) {

decodedCert, err := base64.StdEncoding.DecodeString(caCrt)

if err != nil {
Expand Down Expand Up @@ -59,23 +71,7 @@ func TestConfig(t *testing.T) {

}

func TestLoadManifestForPrivateService(t *testing.T) {
namespace := "custom"
commitSha := "93f4be93"

proj := &project.Project{Name: "knative_test",
Directory: path.Join(root, "example"),
Resources: os.DirFS(root),
IsPrivate: false,
}

dockerImage := docker.DockerImage{
Registry: "example.com",
Directory: ".",
Name: "test",
Tag: "v1.1.0",
}

func TestLoadManifestForPublicService(t *testing.T) {
serviceManifest, err := LoadManifest(namespace, commitSha, proj, dockerImage, envSampleFile, secretRefEnvSampleFile)

if err != nil {
Expand All @@ -91,17 +87,12 @@ func TestLoadManifestForPrivateService(t *testing.T) {
assert.Assert(t, !ok, "Visibility label should not be set for public services")
}

func TestLoadManifestForPublicService(t *testing.T) {
namespace := "custom"
commitSha := "93f4be93"
func TestLoadManifestForPrivateService(t *testing.T) {
imagePullSecrets := []string{"secretPassword123"}

proj := &project.Project{Name: "knative_test",
Directory: path.Join(root, "example"),
Resources: os.DirFS(root),
ImagePullSecrets: imagePullSecrets,
IsPrivate: true,
}
privateProj := proj
privateProj.IsPrivate = true
privateProj.ImagePullSecrets = imagePullSecrets

dockerImage := docker.DockerImage{
Registry: "example.com",
Expand All @@ -110,7 +101,7 @@ func TestLoadManifestForPublicService(t *testing.T) {
Tag: "v1.1.0",
}

serviceManifest, err := LoadManifest(namespace, commitSha, proj, dockerImage, envSampleFile, secretRefEnvSampleFile)
serviceManifest, err := LoadManifest(namespace, commitSha, privateProj, dockerImage, envSampleFile, secretRefEnvSampleFile)

if err != nil {
t.Fatalf(fmt.Sprintf("Error: %v", err))
Expand Down

0 comments on commit 57923f4

Please sign in to comment.