mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
go.mod still declared `module github.com/hanzoai/deploy` after the repo was renamed. A Go module path is not cosmetic — it is the resolvable location. So `go get github.com/hanzoai/cd` could not work, and anything importing this module had to spell a name that no longer exists at that address. The build log of v3.6.0 is where it surfaced: the compiler was still emitting github.com/hanzoai/deploy/cmd/cd/commands. 3541 import paths across 690 .go, 19 .proto, 4 .yaml, 3 .sh, 2 .mod, Procfile and Makefile. Plus the 62 ghcr.io/hanzoai/deploy image references, moved to ghcr.io/hanzoai/cd to match hanzo.yml's build target — a distinct string from the module path, replaced separately so neither could clobber the other. go mod tidy clean, CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ./... clean. Co-authored-by: Hanzo Dev <[email protected]>
102 lines
2.5 KiB
Go
102 lines
2.5 KiB
Go
package hydrator
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
"github.com/hanzoai/cd/pkg/apis/application/v1alpha1"
|
|
"github.com/hanzoai/cd/util/settings"
|
|
)
|
|
|
|
func TestRender(t *testing.T) {
|
|
t.Parallel()
|
|
tests := []struct {
|
|
name string
|
|
metadata HydratorCommitMetadata
|
|
want string
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "author and multiple references",
|
|
metadata: HydratorCommitMetadata{
|
|
RepoURL: "https://github.com/test/cd-example-apps",
|
|
DrySHA: "3ff41cc5247197a6caf50216c4c76cc29d78a97d",
|
|
Author: "test <[email protected]>",
|
|
Date: metav1.Now().String(),
|
|
References: []v1alpha1.RevisionReference{
|
|
{
|
|
Commit: &v1alpha1.CommitMetadata{
|
|
Author: "ref test <[email protected]>",
|
|
Subject: "test",
|
|
RepoURL: "https://github.com/test/cd-example-apps",
|
|
SHA: "3ff41cc5247197a6caf50216c4c76cc29d78a97c",
|
|
},
|
|
},
|
|
{
|
|
Commit: &v1alpha1.CommitMetadata{
|
|
Author: "ref test 2 <[email protected]>",
|
|
Subject: "test 2",
|
|
RepoURL: "https://github.com/test/cd-example-apps",
|
|
SHA: "abc12345678912345678912345678912345678912",
|
|
},
|
|
},
|
|
},
|
|
Body: "testBody",
|
|
Subject: "testSubject",
|
|
},
|
|
want: `3ff41cc: testSubject
|
|
|
|
testBody
|
|
|
|
Co-authored-by: ref test <[email protected]>
|
|
Co-authored-by: ref test 2 <[email protected]>
|
|
Co-authored-by: test <[email protected]>
|
|
`,
|
|
},
|
|
{
|
|
name: "no references",
|
|
metadata: HydratorCommitMetadata{
|
|
RepoURL: "https://github.com/test/cd-example-apps",
|
|
DrySHA: "3ff41cc5247197a6caf50216c4c76cc29d78a97d",
|
|
Author: "test <[email protected]>",
|
|
Date: metav1.Now().String(),
|
|
Body: "testBody",
|
|
Subject: "testSubject",
|
|
},
|
|
want: `3ff41cc: testSubject
|
|
|
|
testBody
|
|
|
|
Co-authored-by: test <[email protected]>
|
|
`,
|
|
},
|
|
{
|
|
name: "no body",
|
|
metadata: HydratorCommitMetadata{
|
|
RepoURL: "https://github.com/test/cd-example-apps",
|
|
DrySHA: "3ff41cc5247197a6caf50216c4c76cc29d78a97d",
|
|
Author: "test <[email protected]>",
|
|
Date: metav1.Now().String(),
|
|
Subject: "testSubject",
|
|
},
|
|
want: `3ff41cc: testSubject
|
|
|
|
Co-authored-by: test <[email protected]>
|
|
`,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
got, err := Render(settings.CommitMessageTemplate, tt.metadata)
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("Render() error = %v, wantErr %v", err, tt.wantErr)
|
|
return
|
|
}
|
|
assert.Equal(t, tt.want, got)
|
|
})
|
|
}
|
|
}
|