MCPcopy Index your code
hub / github.com/bytebase/bytebase / TestGetVCSUserSkipsGitLabBotAuthor

Function TestGetVCSUserSkipsGitLabBotAuthor

action/command/vcs_user_test.go:88–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

86}
87
88func TestGetVCSUserSkipsGitLabBotAuthor(t *testing.T) {
89 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
90 w.Header().Set("Content-Type", "application/json")
91 _, err := w.Write([]byte(`{"author":{"id":4004,"username":"project_987_bot_a1b2c3","name":"Project bot"}}`))
92 require.NoError(t, err)
93 }))
94 t.Cleanup(server.Close)
95
96 t.Setenv("CI_MERGE_REQUEST_PROJECT_ID", "987")
97 t.Setenv("CI_MERGE_REQUEST_IID", "42")
98 t.Setenv("CI_API_V4_URL", server.URL+"/api/v4")
99 t.Setenv("CI_JOB_TOKEN", "job-token")
100
101 require.Nil(t, getVCSUser(world.GitLab))
102}
103
104func TestGetVCSUserSkipsBitbucketWhenAuthorUnavailable(t *testing.T) {
105 t.Setenv("BITBUCKET_PR_ID", "10")

Callers

nothing calls this directly

Calls 2

getVCSUserFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected