-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(hatchery): fix worker model name for all hatcheries (#5013)
* fix(hatchery): fix worker model name for all hatcheries Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
- Loading branch information
Showing
4 changed files
with
87 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package hatchery | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func Test_generateWorkerName(t *testing.T) { | ||
type args struct { | ||
hatcheryName string | ||
isRegister bool | ||
model string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
}{ | ||
{ | ||
name: "simple", | ||
args: args{hatcheryName: "p999-prod", isRegister: true, model: "shared.infra-rust-official-1.41"}, | ||
want: "register-p999-prod-shared.infra-ru", | ||
}, | ||
{ | ||
name: "long hatchery name", | ||
args: args{hatcheryName: "p999-prod-xxxx-xxxx-xxxx-xxxx-xxxx", isRegister: true, model: "shared.infra-rust-official-1.41"}, | ||
want: "register-shared.infra-ru", | ||
}, | ||
{ | ||
name: "long model name", | ||
args: args{hatcheryName: "hname", isRegister: true, model: "shared.infra-rust-official-1.41-xxx-xxx-xxx-xxx"}, | ||
want: "register-hname-shared.infra-ru", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := generateWorkerName(tt.args.hatcheryName, tt.args.isRegister, tt.args.model) | ||
if len(got) > 64 { | ||
t.Errorf("len must be < 64() = %d - got:%s", len(got), got) | ||
} | ||
|
||
if !strings.HasPrefix(got, tt.want) { | ||
t.Errorf("generateWorkerName() = %v, want prefix : %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |