@@ -53,49 +53,63 @@ func TestGithubUserLink(t *testing.T) {
5353		bio  bool 
5454	}
5555	tests  :=  []struct  {
56- 		name  string 
57- 		args  args 
58- 		want  string 
56+ 		name      string 
57+ 		mockUser  string 
58+ 		args      args 
59+ 		want      string 
5960	}{{
60- 		name : "normal case without bio" ,
61+ 		name :     "normal case without bio" ,
62+ 		mockUser : "linuxsuren" ,
6163		args : args {
6264			id :  "linuxsuren" ,
6365			bio : false ,
6466		},
6567		want : `[Rick](https://github.com/LinuxSuRen)` ,
6668	}, {
67- 		name : "normal case with bio" ,
69+ 		name :     "normal case with bio" ,
70+ 		mockUser : "linuxsuren" ,
6871		args : args {
6972			id :  "linuxsuren" ,
7073			bio : true ,
7174		},
7275		want : `[Rick](https://github.com/LinuxSuRen) (程序员,业余开源布道者)` ,
7376	}, {
74- 		name : "with whitespace" ,
77+ 		name :     "with whitespace" ,
78+ 		mockUser : "linuxsuren" ,
7579		args : args {
7680			id :  "this is not id" ,
7781			bio : false ,
7882		},
7983		want : "this is not id" ,
8084	}, {
81- 		name : "has Markdown style link" ,
85+ 		name :     "has Markdown style link" ,
86+ 		mockUser : "linuxsuren" ,
8287		args : args {
8388			id :  "[name](link)" ,
8489			bio : false ,
8590		},
8691		want : "[name](link)" ,
8792	}, {
88- 		name : "has Markdown style link, want bio" ,
93+ 		name :     "has Markdown style link, want bio" ,
94+ 		mockUser : "linuxsuren" ,
8995		args : args {
9096			id :  "[Rick](https://github.com/linuxsuren)" ,
9197			bio : true ,
9298		},
9399		want : `[Rick](https://github.com/LinuxSuRen) (程序员,业余开源布道者)` ,
100+ 	}, {
101+ 		name :     "do not have bio" ,
102+ 		mockUser : "linuxsuren-bot" ,
103+ 		args : args {
104+ 			id :  "linuxsuren-bot" ,
105+ 			bio : true ,
106+ 		},
107+ 		want : `[LinuxSuRen-bot](https://github.com/linuxsuren-bot)` ,
94108	}}
95109	for  _ , tt  :=  range  tests  {
96110		t .Run (tt .name , func (t  * testing.T ) {
97111			defer  gock .Off ()
98- 			mockGitHubUser ("linuxsuren" )
112+ 			mockGitHubUser (tt . mockUser )
99113			assert .Equalf (t , tt .want , GithubUserLink (tt .args .id , tt .args .bio ), "GithubUserLink(%v, %v)" , tt .args .id , tt .args .bio )
100114		})
101115	}
0 commit comments