func TestProjectFromName(t *testing.T) { var want = config.Project{Name: "TestProject"} projects := []config.Project{want} got, err := config.ProjectFromName(projects, "TestProject") if err != nil { t.Fatal(err) } if !reflect.DeepEqual(got, want) { t.Errorf("config.GetProjectFromName = %v, want %v", got, want) } got, err = config.ProjectFromName(projects, "BadProject") if err == nil { t.Errorf("config.GetProjectFromName error case did not error") } }
func (h handler) loadProject(projName string, u auth.User) (p config.Project, deployUser string, err error) { c, err := config.Load(h.ecl) if err != nil { glog.Errorf("Parsing etc: %v", err) return config.Project{}, "", err } p, err = config.ProjectFromName(c.Projects, projName) if err != nil { glog.Errorf("Failed to get project from name: %v", err) return config.Project{}, "", err } if !h.ac.Readable(p.RepoOwner, p.RepoName, u.Name) { return config.Project{}, "", projectUnaccessible } return p, c.DeployUser, nil }