Skip to content

Commit

Permalink
Handle empty line when parse bigtable group version file (#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
shifucun authored Mar 9, 2022
1 parent 5c3d9c1 commit d54f46d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,10 @@ func ParseBigtableGroup(s string) []string {
if err == io.EOF {
break
}
tables = append(tables, strings.TrimSpace(string(line)))
t := strings.TrimSpace(string(line))
if t != "" {
tables = append(tables, t)
}
}
return tables
}
15 changes: 15 additions & 0 deletions internal/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,18 @@ func TestKeysToSlice(t *testing.T) {
t.Errorf("places.keysToSlice(%v) = %v; expected %v", m, result, expected)
}
}

func TestParseBigtableGroup(t *testing.T) {
for _, c := range []struct {
input string
want []string
}{
{"table1\ntable2\n\n", []string{"table1", "table2"}},
{"table1 \n table2\n", []string{"table1", "table2"}},
} {
got := ParseBigtableGroup(c.input)
if diff := cmp.Diff(got, c.want); diff != "" {
t.Errorf("ParseBigtableGroup got diff %+v", diff)
}
}
}

0 comments on commit d54f46d

Please sign in to comment.