Skip to content

Different ways of getting issue.getClosedby() return different results. #113

@anthonyms

Description

@anthonyms

The following test case shows that calling issue.getRepository().getIssue(issue.getNumber()) .getClosedBy() at times yields different results from issue.getClosedBy().

Also not all closed issues return the GHuser who closed them whereas github shows the closer of the issue.

import static org.junit.Assert.assertEquals;

import java.io.IOException;

import org.junit.BeforeClass;
import org.junit.Test;
import org.kohsuke.github.GHIssue;
import org.kohsuke.github.GHIssueState;
import org.kohsuke.github.GHRepository;
import org.kohsuke.github.GitHub;

public class IssueTester {

    private  static GHRepository repo;

    @BeforeClass
    public  static void setup() {
        try {
            repo = GitHub.connectAnonymously().getRepository(
                    "kohsuke/github-api");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    // These two ways of gettting closers must return same GHUser
    @Test
    public void testGetCloser() {
        try {
            for (GHIssue issue : repo.getIssues(GHIssueState.CLOSED)) {
                assertEquals(issue.getRepository().getIssue(issue.getNumber())
                        .getClosedBy(), issue.getClosedBy());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    // Every closed issue must have been closed by someone
    @Test
    public void testClosedIssue() {
        try {
            for (GHIssue issue : repo.getIssues(GHIssueState.CLOSED)) {
                assert (issue.getClosedBy() != null);
                assert (issue.getRepository().getIssue(issue.getNumber())
                        .getClosedBy() != null);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions