github.com/nesv/gothub@v0.0.0-20140406181320-f0c824044d5f/organizations_test.go (about)

     1  package gothub
     2  
     3  import "testing"
     4  
     5  func TestGithubOrganizations(t *testing.T) {
     6  	orgs, err := tgh.Organizations()
     7  	if err != nil {
     8  		t.Errorf("%s", err)
     9  	} else {
    10  		t.Logf("You are a member of the following %s organizations:", len(orgs))
    11  		for _, org := range orgs {
    12  			t.Logf("%d\t%s", org.Id, org.Login)
    13  		}
    14  	}
    15  }
    16  
    17  func TestUserOrganizations(t *testing.T) {
    18  	user, err := tgh.GetUser("octocat")
    19  	if err != nil {
    20  		t.Errorf("%s", err)
    21  		return
    22  	}
    23  
    24  	orgs, err := user.Organizations()
    25  	if err != nil {
    26  		t.Errorf("%s", err)
    27  	} else {
    28  		t.Logf("%s is a part of the following %d orgs:", user.Login, len(orgs))
    29  		for _, org := range orgs {
    30  			t.Logf("%d\t%s", org.Id, org.Login)
    31  		}
    32  	}
    33  }
    34  
    35  func TestGetOrganization(t *testing.T) {
    36  	if org, err := tgh.GetOrganization("github"); err != nil {
    37  		t.Errorf("%s", err)
    38  	} else {
    39  		t.Logf("Successfully fetched organization \"%s\"", org.Name)
    40  		t.Logf("%#v", org)
    41  	}
    42  }