1 package bulldozesynclabel 2 3 //var c = &plugin.MockGithubClient{GithubIssues: &plugin.MockIssueService{}, GithubPullRequests: &plugin.MockPullRequestService{}} 4 //var hp = &plugin.HandlerParams{ 5 // Ctx: context.Background(), 6 // Client: c, 7 // Org: "some-org", 8 // Repo: "some-repo", 9 // Log: zerolog.New(os.Stdout).With().Timestamp().Logger(), 10 //} 11 12 // test that an ok-to-sync label is added and then removed in sequence 13 //func TestLabel(t *testing.T) { 14 // c.GithubIssues = &plugin.MockIssueService{Labels: []string{}} 15 // 16 // // test if the status event will trigger jack to add the ok-to-sync label 17 // se := &github.StatusEvent{ 18 // Name: github.String("ncrvoyix-swt-retail/edge-infra"), 19 // TargetURL: github.String("https://policy-bot.edge-infra.dev/details/ncrvoyix-swt-retail/edge-infra/2392"), 20 // Context: github.String("mergeable: master"), 21 // Description: github.String("All rules are approved"), 22 // State: github.String("success"), 23 // } 24 // handleStatusEvent(*hp, *se) 25 // 26 // ct := &plugin.MockGithubClient{GithubIssues: &plugin.MockIssueService{Labels: []string{constants.OkToSync}}} 27 // 28 // if !reflect.DeepEqual(ct.GithubIssues, c.GithubIssues) { 29 // t.Error("Failed to add the ok-to-sync label") 30 // } 31 // 32 // // test if jack will ignore other contexts 33 // se.Context = github.String("some-other-plugin") 34 // se.State = github.String("failure") 35 // handleStatusEvent(*hp, *se) 36 // 37 // if !reflect.DeepEqual(ct.GithubIssues, c.GithubIssues) { 38 // t.Error("Failed to ignore status event") 39 // } 40 // 41 // // TODO re-enable this once https://github.com/ncrvoyix-swt-retail/edge-infra/pull/2564 42 // // has been merged so we can use the relatedissue feature 43 // // this will error until then because we need to get the labels from a related issue 44 // // se.Context = github.String("mergeable: master") 45 // // se.State = github.String("failure") 46 // 47 // // handleStatusEvent(*hp, *se) 48 // 49 // // ct = &plugin.MockGithubClient{GithubIssues: &plugin.MockIssueService{Labels: []string{}}} 50 // 51 // // if !reflect.DeepEqual(ct.GithubIssues, c.GithubIssues) { 52 // // t.Error("Failed to remove the ok-to-sync label") 53 // // } 54 //} 55