2023-07-01 11:18:12 +00:00
|
|
|
package tool_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2023-08-15 20:10:26 +00:00
|
|
|
|
|
|
|
"code.icb4dc0.de/buildr/golang-plugin/tool"
|
2023-07-01 11:18:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGoTool_BinaryName(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
type fields struct {
|
|
|
|
BinaryNameOverride string
|
|
|
|
Repository string
|
|
|
|
Version string
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
fields fields
|
|
|
|
want string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "Override",
|
|
|
|
fields: fields{
|
|
|
|
BinaryNameOverride: "go-buildr",
|
|
|
|
Repository: "code.icb4dc0.de/buildr/buildr",
|
|
|
|
},
|
|
|
|
want: "go-buildr",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "No override, no inline-version, no version suffix",
|
|
|
|
fields: fields{
|
|
|
|
Repository: "code.icb4dc0.de/buildr/buildr",
|
|
|
|
},
|
|
|
|
want: "buildr",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "No override, no inline-version, version suffix",
|
|
|
|
fields: fields{
|
|
|
|
Repository: "code.icb4dc0.de/buildr/buildr/v2",
|
|
|
|
},
|
|
|
|
want: "buildr",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "No override, inline-version, no version suffix",
|
|
|
|
fields: fields{
|
|
|
|
Repository: "code.icb4dc0.de/buildr/buildr@latest",
|
|
|
|
},
|
|
|
|
want: "buildr",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "No override, inline-version, version suffix",
|
|
|
|
fields: fields{
|
|
|
|
Repository: "code.icb4dc0.de/buildr/buildr/v2@latest",
|
|
|
|
},
|
|
|
|
want: "buildr",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
tt := tt
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
g := tool.GoTool{
|
|
|
|
BinaryNameOverride: tt.fields.BinaryNameOverride,
|
|
|
|
Repository: tt.fields.Repository,
|
|
|
|
Version: tt.fields.Version,
|
|
|
|
}
|
|
|
|
if got := g.BinaryName(); got != tt.want {
|
|
|
|
t.Errorf("BinaryName() = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|