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

Configure Feed

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

1// Copyright 2016 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 "reflect" 19 "testing" 20) 21 22func TestParseGitModules(t *testing.T) { 23 cases := []struct { 24 data string 25 want map[string]*SubmoduleEntry 26 }{ 27 { 28 `[submodule "plugins/abc"] 29 path = plugins/abc 30 url = ../plugins/abc 31 branch = .`, 32 map[string]*SubmoduleEntry{ 33 "plugins/abc": { 34 Path: "plugins/abc", 35 URL: "../plugins/abc", 36 Branch: ".", 37 }, 38 }, 39 }, 40 { 41 "\uFEFF" + `[submodule "plugins/abc"] 42 path = plugins/abc 43 url = ../plugins/abc 44 branch = .`, 45 map[string]*SubmoduleEntry{ 46 "plugins/abc": { 47 Path: "plugins/abc", 48 URL: "../plugins/abc", 49 Branch: ".", 50 }, 51 }, 52 }, 53 {"", map[string]*SubmoduleEntry{}}, 54 } 55 56 for _, tc := range cases { 57 got, err := ParseGitModules([]byte(tc.data)) 58 if err != nil { 59 t.Fatalf("ParseGitModules: %T", err) 60 } 61 62 if !reflect.DeepEqual(got, tc.want) { 63 t.Fatalf("got %v, want %v", got, tc.want) 64 } 65 } 66}