fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

1// Copyright 2017 Google Inc. All rights reserved. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package gitindex 16 17import ( 18 "net/url" 19 "reflect" 20 "sort" 21 "testing" 22) 23 24func TestListReposNonExistent(t *testing.T) { 25 u, err := url.Parse("https://gerrit.googlesource.com/") 26 if err != nil { 27 t.Fatalf("url.Parse: %v", err) 28 } 29 30 rs, err := ListRepos("/doesnotexist", u) 31 if err == nil { 32 t.Fatalf("ListRepos(/doesnotexist): %v", rs) 33 } 34} 35 36func TestListRepos(t *testing.T) { 37 dir := t.TempDir() 38 39 if err := createSubmoduleRepo(dir); err != nil { 40 t.Fatalf("createSubmoduleRepo %v", err) 41 } 42 43 u, err := url.Parse("https://gerrit.googlesource.com/") 44 if err != nil { 45 t.Fatalf("url.Parse: %v", err) 46 } 47 rs, err := ListRepos(dir, u) 48 if err != nil { 49 t.Fatalf("ListRepos(%s): %v", u, err) 50 } 51 52 want := []string{ 53 "gerrit.googlesource.com/adir.git", 54 "gerrit.googlesource.com/bdir.git", 55 "gerrit.googlesource.com/sub/bdir.git", 56 "gerrit.googlesource.com/team/scope/repoa.git", 57 "gerrit.googlesource.com/team/scope/repob.git", 58 } 59 sort.Strings(rs) 60 61 if !reflect.DeepEqual(rs, want) { 62 t.Fatalf("got %v, want %v", rs, want) 63 } 64}