github.com/mistwind/reviewdog@v0.0.0-20230322024206-9cfa11856d58/cienv/github_actions_test.go (about) 1 package cienv 2 3 import ( 4 "testing" 5 6 "github.com/google/go-cmp/cmp" 7 ) 8 9 func TestGetBuildInfoFromGitHubActionEventPath_prevent(t *testing.T) { 10 got, _, err := getBuildInfoFromGitHubActionEventPath("_testdata/github_event_pull_request.json") 11 if err != nil { 12 t.Fatal(err) 13 } 14 want := &BuildInfo{Owner: "reviewdog", Repo: "reviewdog", SHA: "cb23119096646023c05e14ea708b7f20cee906d5", PullRequest: 285, Branch: "go1.13"} 15 if diff := cmp.Diff(got, want); diff != "" { 16 t.Errorf("result has diff:\n%s", diff) 17 } 18 } 19 20 func TestGetBuildInfoFromGitHubActionEventPath_rerunevent(t *testing.T) { 21 got, _, err := getBuildInfoFromGitHubActionEventPath("_testdata/github_event_rerun.json") 22 if err != nil { 23 t.Fatal(err) 24 } 25 want := &BuildInfo{Owner: "reviewdog", Repo: "reviewdog", SHA: "ba8f36cd3eb401e9de9ee5718e11d390fdbe4afa", PullRequest: 286, Branch: "github-actions-env"} 26 if diff := cmp.Diff(got, want); diff != "" { 27 t.Errorf("result has diff:\n%s", diff) 28 } 29 } 30 31 func TestGetBuildInfoFromGitHubActionEventPath_pushevent(t *testing.T) { 32 got, _, err := getBuildInfoFromGitHubActionEventPath("_testdata/github_event_push.json") 33 if err != nil { 34 t.Fatal(err) 35 } 36 want := &BuildInfo{Owner: "reviewdog", Repo: "reviewdog", SHA: "febdd4bf26c6e8856c792303cfc66fa5e7bc975b"} 37 if diff := cmp.Diff(got, want); diff != "" { 38 t.Errorf("result has diff:\n%s", diff) 39 } 40 }