MCPcopy Index your code
hub / github.com/google/go-github / TestProjectsService_AddUserProjectItem

Function TestProjectsService_AddUserProjectItem

github/projects_test.go:1072–1092  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1070}
1071
1072func TestProjectsService_AddUserProjectItem(t *testing.T) {
1073 t.Parallel()
1074 client, mux, _ := setup(t)
1075 mux.HandleFunc("/users/u/projectsV2/2/items", func(w http.ResponseWriter, r *http.Request) {
1076 testMethod(t, r, "POST")
1077 b, _ := io.ReadAll(r.Body)
1078 body := string(b)
1079 if body != `{"type":"PullRequest","id":123}`+"\n" {
1080 t.Fatalf("unexpected body: %s", body)
1081 }
1082 fmt.Fprint(w, `{"id":123,"node_id":"PVTI_new_user"}`)
1083 })
1084 ctx := t.Context()
1085 item, _, err := client.Projects.AddUserProjectItem(ctx, "u", 2, &AddProjectItemOptions{Type: Ptr(ProjectV2ItemContentType("PullRequest")), ID: Ptr(int64(123))})
1086 if err != nil {
1087 t.Fatalf("AddUserProjectItem error: %v", err)
1088 }
1089 if item.GetID() != 123 {
1090 t.Fatalf("unexpected item: %+v", item)
1091 }
1092}
1093
1094func TestProjectsService_AddUserProjectItem_error(t *testing.T) {
1095 t.Parallel()

Callers

nothing calls this directly

Calls 6

testMethodFunction · 0.85
ProjectV2ItemContentTypeTypeAlias · 0.85
AddUserProjectItemMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70
GetIDMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…