|  | 
| 5 | 5 | 	"os" | 
| 6 | 6 | 	"testing" | 
| 7 | 7 | 
 | 
|  | 8 | +	"github.com/andreyvit/diff" | 
| 8 | 9 | 	"github.com/uselagoon/build-deploy-tool/internal/dbaasclient" | 
| 9 | 10 | 	"github.com/uselagoon/build-deploy-tool/internal/generator" | 
| 10 | 11 | 	"github.com/uselagoon/build-deploy-tool/internal/helpers" | 
| @@ -752,6 +753,61 @@ func TestImageBuildConfigurationIdentification(t *testing.T) { | 
| 752 | 753 | 				}, | 
| 753 | 754 | 			}, | 
| 754 | 755 | 		}, | 
|  | 756 | +		{ | 
|  | 757 | +			name: "test12 Force Pull Base Images with variable replacement", | 
|  | 758 | +			args: testdata.GetSeedData( | 
|  | 759 | +				testdata.TestData{ | 
|  | 760 | +					Namespace:       "example-project-main", | 
|  | 761 | +					ProjectName:     "example-project", | 
|  | 762 | +					EnvironmentName: "main", | 
|  | 763 | +					Branch:          "main", | 
|  | 764 | +					LagoonYAML:      "internal/testdata/basic/lagoon.forcebaseimagepull-2.yml", | 
|  | 765 | +					ProjectVariables: []lagoon.EnvironmentVariable{ | 
|  | 766 | +						{ | 
|  | 767 | +							Name:  "BASE_IMAGE_TAG", | 
|  | 768 | +							Value: "my-tag", | 
|  | 769 | +							Scope: "build", | 
|  | 770 | +						}, | 
|  | 771 | +						{ | 
|  | 772 | +							Name:  "BASE_IMAGE_REPO", | 
|  | 773 | +							Value: "my-repo", | 
|  | 774 | +							Scope: "build", | 
|  | 775 | +						}, | 
|  | 776 | +					}, | 
|  | 777 | +				}, true), | 
|  | 778 | +			want: imageBuild{ | 
|  | 779 | +				BuildKit: helpers.BoolPtr(true), | 
|  | 780 | +				BuildArguments: map[string]string{ | 
|  | 781 | +					"BASE_IMAGE_TAG":               "my-tag", | 
|  | 782 | +					"BASE_IMAGE_REPO":              "my-repo", | 
|  | 783 | +					"LAGOON_BUILD_NAME":            "lagoon-build-abcdefg", | 
|  | 784 | +					"LAGOON_PROJECT":               "example-project", | 
|  | 785 | +					"LAGOON_ENVIRONMENT":           "main", | 
|  | 786 | +					"LAGOON_ENVIRONMENT_TYPE":      "production", | 
|  | 787 | +					"LAGOON_BUILD_TYPE":            "branch", | 
|  | 788 | +					"LAGOON_GIT_SOURCE_REPOSITORY": "ssh://git@example.com/lagoon-demo.git", | 
|  | 789 | +					"LAGOON_KUBERNETES":            "remote-cluster1", | 
|  | 790 | +					"LAGOON_GIT_SHA":               "abcdefg123456", | 
|  | 791 | +					"LAGOON_GIT_BRANCH":            "main", | 
|  | 792 | +					"NODE_IMAGE":                   "example-project-main-node", | 
|  | 793 | +					"LAGOON_SSH_PRIVATE_KEY":       "-----BEGIN OPENSSH PRIVATE KEY-----\nthisisafakekey\n-----END OPENSSH PRIVATE KEY-----", | 
|  | 794 | +				}, | 
|  | 795 | +				ForcePullImages: []string{ | 
|  | 796 | +					"registry.com/my-repo/imagename:my-tag", | 
|  | 797 | +				}, | 
|  | 798 | +				Images: []imageBuilds{ | 
|  | 799 | +					{ | 
|  | 800 | +						Name: "node", | 
|  | 801 | +						ImageBuild: generator.ImageBuild{ | 
|  | 802 | +							BuildImage:     "harbor.example/example-project/main/node:latest", | 
|  | 803 | +							Context:        "internal/testdata/basic/docker", | 
|  | 804 | +							DockerFile:     "basic.dockerfile", | 
|  | 805 | +							TemporaryImage: "example-project-main-node", | 
|  | 806 | +						}, | 
|  | 807 | +					}, | 
|  | 808 | +				}, | 
|  | 809 | +			}, | 
|  | 810 | +		}, | 
| 755 | 811 | 	} | 
| 756 | 812 | 	for _, tt := range tests { | 
| 757 | 813 | 		t.Run(tt.name, func(t *testing.T) { | 
| @@ -788,10 +844,10 @@ func TestImageBuildConfigurationIdentification(t *testing.T) { | 
| 788 | 844 | 				t.Errorf("%v", err) | 
| 789 | 845 | 			} | 
| 790 | 846 | 
 | 
| 791 |  | -			oJ, _ := json.Marshal(out) | 
| 792 |  | -			wJ, _ := json.Marshal(tt.want) | 
|  | 847 | +			oJ, _ := json.MarshalIndent(out, "", "  ") | 
|  | 848 | +			wJ, _ := json.MarshalIndent(tt.want, "", "  ") | 
| 793 | 849 | 			if string(oJ) != string(wJ) { | 
| 794 |  | -				t.Errorf("returned output %v doesn't match want %v", string(oJ), string(wJ)) | 
|  | 850 | +				t.Errorf("ImageBuildConfigurationIdentification() = \n%v", diff.LineDiff(string(oJ), string(wJ))) | 
| 795 | 851 | 			} | 
| 796 | 852 | 			t.Cleanup(func() { | 
| 797 | 853 | 				helpers.UnsetEnvVars(tt.vars) | 
|  | 
0 commit comments