(t *testing.T)
| 675 | } |
| 676 | |
| 677 | func TestCheckIssue(t *testing.T) { |
| 678 | tests := []struct { |
| 679 | name string |
| 680 | number int |
| 681 | isPullRequest bool |
| 682 | lookupErr error |
| 683 | wantErr string |
| 684 | }{ |
| 685 | { |
| 686 | name: "an issue", |
| 687 | number: 142, |
| 688 | }, |
| 689 | { |
| 690 | name: "a pull request", |
| 691 | number: 158, |
| 692 | isPullRequest: true, |
| 693 | wantErr: "monalisa/monas-cafe#158 is a pull request; artifacts are only supported on issues", |
| 694 | }, |
| 695 | { |
| 696 | name: "the lookup's error", |
| 697 | number: 999, |
| 698 | lookupErr: errors.New("GraphQL: Could not resolve to an issue or pull request with the number of 999. (repository.issue)"), |
| 699 | wantErr: "GraphQL: Could not resolve to an issue or pull request with the number of 999. (repository.issue)", |
| 700 | }, |
| 701 | } |
| 702 | |
| 703 | for _, tt := range tests { |
| 704 | t.Run(tt.name, func(t *testing.T) { |
| 705 | repo := ghrepo.New("monalisa", "monas-cafe") |
| 706 | mock := &client.ArtifactClientMock{ |
| 707 | IsPullRequestFunc: func(ghrepo.Interface, int) (bool, error) { |
| 708 | return tt.isPullRequest, tt.lookupErr |
| 709 | }, |
| 710 | } |
| 711 | |
| 712 | err := CheckIssue(mock, repo, tt.number) |
| 713 | |
| 714 | require.Len(t, mock.IsPullRequestCalls(), 1) |
| 715 | assert.Equal(t, repo, mock.IsPullRequestCalls()[0].Repo) |
| 716 | assert.Equal(t, tt.number, mock.IsPullRequestCalls()[0].Number) |
| 717 | if tt.wantErr != "" { |
| 718 | require.EqualError(t, err, tt.wantErr) |
| 719 | return |
| 720 | } |
| 721 | require.NoError(t, err) |
| 722 | }) |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | func TestCheckUploadTarget(t *testing.T) { |
| 727 | tests := []struct { |
nothing calls this directly
no test coverage detected