Skip to content

Commit

Permalink
fix(dsref): Change char to character in dsref.parse errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dustmop committed May 19, 2020
1 parent 2f97a4e commit 83882b0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/save_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func TestSaveBasicCommands(t *testing.T) {
{
"dataset file explicit version",
"qri save --file dataset.yaml me/my_dataset@/ipfs/QmVersion",
"unexpected char '@', ref can only have username/name",
"unexpected character '@', ref can only have username/name",
},
{
"body file other username",
Expand Down
8 changes: 4 additions & 4 deletions dsref/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ var (
// ErrParseError is an error returned when parsing fails
ErrParseError = fmt.Errorf("could not parse ref")
// ErrUnexpectedChar is an error when a character is unexpected, topic string must be non-empty
ErrUnexpectedChar = fmt.Errorf("unexpected char")
ErrUnexpectedChar = fmt.Errorf("unexpected character")
// ErrNotHumanFriendly is an error returned when a reference is not human-friendly
ErrNotHumanFriendly = fmt.Errorf("unexpected char '@', ref can only have username/name")
ErrNotHumanFriendly = fmt.Errorf("unexpected character '@', ref can only have username/name")
// ErrBadCaseName is the error when a bad case is used in the dataset name
ErrBadCaseName = fmt.Errorf("dataset name may not contain any upper-case letters")
// ErrBadCaseUsername is for when a username contains upper-case letters
Expand Down Expand Up @@ -94,7 +94,7 @@ func Parse(text string) (Ref, error) {

if text != "" {
pos := origLength - len(text)
return r, fmt.Errorf("unexpected char at position %d: '%c'", pos, text[0])
return r, fmt.Errorf("unexpected character at position %d: '%c'", pos, text[0])
}

// Dataset names are not supposed to contain upper-case characters. For now, return an error
Expand Down Expand Up @@ -130,7 +130,7 @@ func ParseHumanFriendly(text string) (Ref, error) {
return r, ErrNotHumanFriendly
}
pos := origLength - len(text)
return r, fmt.Errorf("unexpected char at position %d: '%c'", pos, text[0])
return r, fmt.Errorf("unexpected character at position %d: '%c'", pos, text[0])
}

// Dataset names are not supposed to contain upper-case characters. For now, return an error
Expand Down
18 changes: 9 additions & 9 deletions dsref/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ func TestParseFull(t *testing.T) {
text string
expectErr string
}{
{"missing at", "/ipfs/QmThis", "unexpected char at position 0: '/'"},
{"missing at", "/ipfs/QmThis", "unexpected character at position 0: '/'"},
{"invalid base58", "@/ipfs/QmOne", "path contains invalid base58 characters"},
{"no slash", "foo", "need username separated by '/' from dataset name"},
{"http url", "https://apple.com", "unexpected char at position 5: ':'"},
{"domain name", "apple.com", "unexpected char at position 5: '.'"},
{"local filename", "foo.json", "unexpected char at position 3: '.'"},
{"absolute filepath", "/usr/local/bin/file.cbor", "unexpected char at position 0: '/'"},
{"absolute dirname", "/usr/local/bin", "unexpected char at position 0: '/'"},
{"dot in dataset", "abc/data.set", "unexpected char at position 8: '.'"},
{"equals in dataset", "abc/my+ds", "unexpected char at position 6: '+'"},
{"http url", "https://apple.com", "unexpected character at position 5: ':'"},
{"domain name", "apple.com", "unexpected character at position 5: '.'"},
{"local filename", "foo.json", "unexpected character at position 3: '.'"},
{"absolute filepath", "/usr/local/bin/file.cbor", "unexpected character at position 0: '/'"},
{"absolute dirname", "/usr/local/bin", "unexpected character at position 0: '/'"},
{"dot in dataset", "abc/data.set", "unexpected character at position 8: '.'"},
{"equals in dataset", "abc/my+ds", "unexpected character at position 6: '+'"},
}
for i, c := range badCases {
_, err := Parse(c.text)
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestParseHumanFriendly(t *testing.T) {
{"only name", "my_dataset", "need username separated by '/' from dataset name"},
{"right hand side", "@QmFirst/ipfs/QmSecond", ErrNotHumanFriendly.Error()},
{"just path", "@/ipfs/QmSecond", ErrNotHumanFriendly.Error()},
{"missing at", "/ipfs/QmThis", "unexpected char at position 0: '/'"},
{"missing at", "/ipfs/QmThis", "unexpected character at position 0: '/'"},
{"invalid base58", "@/ipfs/QmOne", ErrNotHumanFriendly.Error()},
}
for i, c := range badCases {
Expand Down
2 changes: 1 addition & 1 deletion lib/fsi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestFSIMethodsWrite(t *testing.T) {
{"empty reference", FSIWriteParams{Ref: ""}},
{"dataset name may not contain any upper-case letters", FSIWriteParams{Ref: "abc/ABC"}},
{"dataset is required", FSIWriteParams{Ref: "abc/movies"}},
{"unexpected char at position 0: '\xc3\xb0'", FSIWriteParams{Ref: "👋", Ds: &dataset.Dataset{}}},
{"unexpected character at position 0: '\xc3\xb0'", FSIWriteParams{Ref: "👋", Ds: &dataset.Dataset{}}},
{"repo: not found", FSIWriteParams{Ref: "abc/movies", Ds: &dataset.Dataset{}}},
{"dataset is not linked to the filesystem", FSIWriteParams{Ref: "peer/movies", Ds: &dataset.Dataset{}}},
}
Expand Down

0 comments on commit 83882b0

Please sign in to comment.