karmada icon indicating copy to clipboard operation
karmada copied to clipboard

add ut for pkg/version/version.go

Open my-git9 opened this issue 3 years ago • 1 comments

What type of PR is this? add ut for pkg/version/version.go

/kind cleanup

What this PR does / why we need it:

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


my-git9 avatar Sep 26 '22 13:09 my-git9

Thanks for contribution

jwcesign avatar Sep 27 '22 03:09 jwcesign

Hi @my-git9, thanks a lot! You can pick the related task as #2579 said.

XiShanYongYe-Chang avatar Sep 27 '22 03:09 XiShanYongYe-Chang

Hi @my-git9, thanks a lot! You can pick the related task as #2579 said.

OK~~

my-git9 avatar Sep 27 '22 12:09 my-git9

I made some changes on your patch, please reference:

func TestInfo_String(t *testing.T) {
	tests := []struct {
		name string
		info Info
		want string
	}{
		{
			name: "test1",
			info: Info{
				GitVersion:   "1.3.0",
				GitCommit:    "da070e68f3318410c8c70ed8186a2bc4736dacbd",
				GitTreeState: "clean",
				BuildDate:    "2022-08-31T13:09:22Z",
				GoVersion:    "go1.18.3",
				Compiler:     "gc",
				Platform:     "linux/amd64",
			},
			want: `version.Info{GitVersion:"1.3.0", GitCommit:"da070e68f3318410c8c70ed8186a2bc4736dacbd", GitTreeState:"clean", BuildDate:"2022-08-31T13:09:22Z", GoVersion:"go1.18.3", Compiler:"gc", Platform:"linux/amd64"}`,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := tt.info.String(); got != tt.want {
				t.Errorf("Info.String() = %v, want %v", got, tt.want)
			}
		})
	}
}

Thanks a lot!

my-git9 avatar Sep 27 '22 13:09 my-git9

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

karmada-bot avatar Sep 28 '22 00:09 karmada-bot