Skip to content

Commit

Permalink
Fix identifier tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcieslak committed Aug 16, 2024
1 parent 5b2a10a commit 153ec00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pkg/sdk/identifier_parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ func parseIdentifier[T ObjectIdentifier](identifier string, expectedParts int, e
}

func ParseAccountObjectIdentifier(identifier string) (AccountObjectIdentifier, error) {
if !(strings.HasPrefix(identifier, `"`) && strings.HasSuffix(identifier, `"`)) {
identifier = fmt.Sprintf(`"%s"`, identifier)
}
return parseIdentifier[AccountObjectIdentifier](
identifier, 1, "<account_object_name>",
func(parts []string) AccountObjectIdentifier {
Expand Down
8 changes: 4 additions & 4 deletions pkg/sdk/identifier_parsers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ func Test_IdentifierParsers(t *testing.T) {
Expected ObjectIdentifier
Error string
}{
{IdentifierType: "AccountObjectIdentifier", Input: ``, Error: "incompatible identifier: "},
{IdentifierType: "AccountObjectIdentifier", Input: "a\nb", Error: "incompatible identifier: a\nb"},
{IdentifierType: "AccountObjectIdentifier", Input: `a"b`, Error: "unable to read identifier: a\"b, err = parse error on line 1, column 2: bare \" in non-quoted-field"},
{IdentifierType: "AccountObjectIdentifier", Input: `abc.cde`, Error: `unexpected number of parts 2 in identifier abc.cde, expected 1 in a form of "<account_object_name>"`},
{IdentifierType: "AccountObjectIdentifier", Input: `a"b`, Error: "unable to read identifier: \"a\"b\", err = parse error on line 1, column 3: extraneous or missing \" in quoted-field"},
{IdentifierType: "AccountObjectIdentifier", Input: `""""`, Error: `unable to parse identifier: """", currently identifiers containing double quotes are not supported in the provider`},
{IdentifierType: "AccountObjectIdentifier", Input: `"a""bc"`, Error: `unable to parse identifier: "a""bc", currently identifiers containing double quotes are not supported in the provider`},
{IdentifierType: "AccountObjectIdentifier", Input: ``, Expected: NewAccountObjectIdentifier(``)},
{IdentifierType: "AccountObjectIdentifier", Input: "a\nb", Expected: NewAccountObjectIdentifier("a\nb")},
{IdentifierType: "AccountObjectIdentifier", Input: `abc.cde`, Expected: NewAccountObjectIdentifier(`abc.cde`)},
{IdentifierType: "AccountObjectIdentifier", Input: `""`, Expected: NewAccountObjectIdentifier(``)},
{IdentifierType: "AccountObjectIdentifier", Input: `abc`, Expected: NewAccountObjectIdentifier(`abc`)},
{IdentifierType: "AccountObjectIdentifier", Input: `"abc"`, Expected: NewAccountObjectIdentifier(`abc`)},
Expand Down

0 comments on commit 153ec00

Please sign in to comment.