Skip to content

Commit

Permalink
test: update test directory structures
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Jun 12, 2022
1 parent 235f7b0 commit b9eaafc
Show file tree
Hide file tree
Showing 133 changed files with 2,178 additions and 167 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.idea
cmd/test-resources/template-routes/output
test-resources/output
24 changes: 12 additions & 12 deletions cmd/identify_feature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func TestIdentifyFeatureFlag(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FEATURE_FLAG_ROOTLESS_WORKLOAD","value":"enabled","scope":"build"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/single-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-feature/alltest/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "enabled",
},
Expand All @@ -75,8 +75,8 @@ func TestIdentifyFeatureFlag(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`,
envVars: `[{"name":"LAGOON_FEATURE_FLAG_ROOTLESS_WORKLOAD","value":"enabled","scope":"build"}]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/single-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-feature/alltest/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "enabled",
},
Expand All @@ -95,8 +95,8 @@ func TestIdentifyFeatureFlag(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/single-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-feature/alltest/lagoon.yml",
templatePath: "../test-resources/output",
},
vars: []struct {
name string
Expand Down Expand Up @@ -124,8 +124,8 @@ func TestIdentifyFeatureFlag(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/single-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-feature/alltest/lagoon.yml",
templatePath: "../test-resources/output",
},
vars: []struct {
name string
Expand Down Expand Up @@ -157,8 +157,8 @@ func TestIdentifyFeatureFlag(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FEATURE_FLAG_ROOTLESS_WORKLOAD","value":"enabled","scope":"build"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/single-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-feature/alltest/lagoon.yml",
templatePath: "../test-resources/output",
},
vars: []struct {
name string
Expand Down Expand Up @@ -190,8 +190,8 @@ func TestIdentifyFeatureFlag(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FEATURE_FLAG_ROOTLESS_WORKLOAD","value":"enabled","scope":"build"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/single-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-feature/alltest/lagoon.yml",
templatePath: "../test-resources/output",
},
vars: []struct {
name string
Expand Down
86 changes: 56 additions & 30 deletions cmd/identify_ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func TestIdentifyRoute(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true:annotationscom","scope":"build"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/single-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-ingress/test1/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "https://example.com",
wantRemain: []string{"https://node-example-project-main.example.com", "https://example.com"},
Expand All @@ -75,8 +75,8 @@ func TestIdentifyRoute(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_IDS","value":"example.com:service-id:true","scope":"build"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/single-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-ingress/test2/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "https://example.com",
wantRemain: []string{"https://node-example-project-main.example.com", "https://example.com"},
Expand All @@ -97,8 +97,8 @@ func TestIdentifyRoute(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"},{"name":"LAGOON_FASTLY_SERVICE_ID","value":"service-id:true","scope":"build"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/single-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-ingress/test3/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "https://example.com",
wantRemain: []string{"https://node-example-project-main.example.com", "https://example.com"},
Expand All @@ -119,8 +119,8 @@ func TestIdentifyRoute(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/single-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-ingress/test4/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "https://example.com",
wantRemain: []string{"https://node-example-project-main.example.com", "https://example.com"},
Expand All @@ -141,8 +141,8 @@ func TestIdentifyRoute(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/polysite-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-ingress/test5/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "https://multiproject1.com",
wantRemain: []string{"https://node-multiproject1-multiproject.example.com", "https://multiproject1.com"},
Expand All @@ -163,8 +163,8 @@ func TestIdentifyRoute(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/polysite-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-ingress/test6/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "https://multiproject2.com",
wantRemain: []string{"https://node-multiproject2-multiproject.example.com", "https://multiproject2.com"},
Expand All @@ -185,8 +185,8 @@ func TestIdentifyRoute(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/multi-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-ingress/test7/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "https://example.com",
wantRemain: []string{"https://node-example-project-main.example.com", "https://example.com", "https://www.example.com"},
Expand All @@ -207,8 +207,8 @@ func TestIdentifyRoute(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/multi-lagoon2.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-ingress/test8/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "https://customdomain-will-be-main-domain.com",
wantRemain: []string{"https://node-example-project-branch-routes.example.com", "https://customdomain-will-be-main-domain.com", "https://customdomain-will-be-not-be-main-domain.com"},
Expand All @@ -230,8 +230,8 @@ func TestIdentifyRoute(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/activestandby-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-ingress/test9/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "https://active.example.com",
wantRemain: []string{"https://node-example-project-main.example.com", "https://main.example.com", "https://active.example.com"},
Expand All @@ -253,8 +253,8 @@ func TestIdentifyRoute(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/activestandby-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-ingress/test10/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "https://standby.example.com",
wantRemain: []string{"https://node-example-project-main2.example.com", "https://main2.example.com", "https://standby.example.com"},
Expand All @@ -276,8 +276,8 @@ func TestIdentifyRoute(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/noingress-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-ingress/test11/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "https://node-example-project-no-ingress.example.com",
wantRemain: []string{"https://node-example-project-no-ingress.example.com"},
Expand All @@ -299,8 +299,8 @@ func TestIdentifyRoute(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/prefixes-lagoon.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-ingress/test12/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "https://node-example-project-no-ingress.example.com",
wantRemain: []string{
Expand All @@ -320,7 +320,7 @@ func TestIdentifyRoute(t *testing.T) {
wantJSON: `{"primary":"https://node-example-project-no-ingress.example.com","secondary":["https://node-example-project-no-ingress.example.com","https://www.node-example-project-no-ingress.example.com","https://en.node-example-project-no-ingress.example.com","https://de.node-example-project-no-ingress.example.com","https://fi.node-example-project-no-ingress.example.com"],"autogenerated":["https://node-example-project-no-ingress.example.com","https://www.node-example-project-no-ingress.example.com","https://en.node-example-project-no-ingress.example.com","https://de.node-example-project-no-ingress.example.com","https://fi.node-example-project-no-ingress.example.com"]}`,
},
{
name: "test12 no autogenerated routes",
name: "test13 no autogenerated routes",
args: args{
alertContact: "alertcontact",
statusPageID: "statuspageid",
Expand All @@ -333,16 +333,16 @@ func TestIdentifyRoute(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/single-lagoon-noautogen.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-ingress/test13/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "https://example.com",
wantRemain: []string{"https://example.com"},
wantautoGen: []string{},
wantJSON: `{"primary":"https://example.com","secondary":["https://example.com"],"autogenerated":[]}`,
},
{
name: "test13 only autogenerated route",
name: "test14 only autogenerated route",
args: args{
alertContact: "alertcontact",
statusPageID: "statuspageid",
Expand All @@ -355,14 +355,36 @@ func TestIdentifyRoute(t *testing.T) {
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.example.com","scope":"internal_system"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "test-resources/template-ingress/single-lagoon-onlyautogen.yml",
templatePath: "test-resources/template-ingress/output",
lagoonYAML: "../test-resources/identify-ingress/test14/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "https://node-example-project-main.example.com",
wantRemain: []string{"https://node-example-project-main.example.com"},
wantautoGen: []string{"https://node-example-project-main.example.com"},
wantJSON: `{"primary":"https://node-example-project-main.example.com","secondary":["https://node-example-project-main.example.com"],"autogenerated":["https://node-example-project-main.example.com"]}`,
},
{
name: "test15 only autogenerated route complex",
args: args{
alertContact: "alertcontact",
statusPageID: "statuspageid",
projectName: "sales-customer-support",
environmentName: "develop",
environmentType: "development",
buildType: "branch",
lagoonVersion: "v2.7.x",
branch: "develop",
projectVars: `[{"name":"LAGOON_SYSTEM_ROUTER_PATTERN","value":"${service}-${project}-${environment}.ex1.example-web.com","scope":"internal_system"}]`,
envVars: `[]`,
secretPrefix: "fastly-api-",
lagoonYAML: "../test-resources/identify-ingress/test15/lagoon.yml",
templatePath: "../test-resources/output",
},
want: "https://nginx-sales-customer-support-develop.ex1.example-web.com",
wantRemain: []string{"https://nginx-sales-customer-support-develop.ex1.example-web.com"},
wantautoGen: []string{"https://nginx-sales-customer-support-develop.ex1.example-web.com"},
wantJSON: `{"primary":"https://nginx-sales-customer-support-develop.ex1.example-web.com","secondary":["https://nginx-sales-customer-support-develop.ex1.example-web.com"],"autogenerated":["https://nginx-sales-customer-support-develop.ex1.example-web.com"]}`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -387,6 +409,10 @@ func TestIdentifyRoute(t *testing.T) {
if err != nil {
t.Errorf("%v", err)
}
err = os.Setenv("LAGOON_GIT_BRANCH", tt.args.branch)
if err != nil {
t.Errorf("%v", err)
}
err = os.Setenv("PR_NUMBER", tt.args.prNumber)
if err != nil {
t.Errorf("%v", err)
Expand Down
Loading

0 comments on commit b9eaafc

Please sign in to comment.