Skip to content

Commit

Permalink
feat: add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Nov 29, 2024
1 parent 5a1e831 commit b29d8eb
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions utils_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package huaweicloud

import (
"testing"
)

func TestPrepareRecordValueTXTWithQuotes(t *testing.T) {
result := prepareRecordValue("TXT", `"example"`)
expected := []string{`"example"`}
if len(result) != len(expected) || result[0] != expected[0] {
t.Errorf("expected %v, got %v", expected, result)
}
}

func TestPrepareRecordValueTXTWithoutStartingQuote(t *testing.T) {
result := prepareRecordValue("TXT", `example"`)
expected := []string{`"example"`}
if len(result) != len(expected) || result[0] != expected[0] {
t.Errorf("expected %v, got %v", expected, result)
}
}

func TestPrepareRecordValueTXTWithoutEndingQuote(t *testing.T) {
result := prepareRecordValue("TXT", `"example`)
expected := []string{`"example"`}
if len(result) != len(expected) || result[0] != expected[0] {
t.Errorf("expected %v, got %v", expected, result)
}
}

func TestPrepareRecordValueTXTWithoutQuotes(t *testing.T) {
result := prepareRecordValue("TXT", `example`)
expected := []string{`"example"`}
if len(result) != len(expected) || result[0] != expected[0] {
t.Errorf("expected %v, got %v", expected, result)
}
}

func TestPrepareRecordValueNonTXT(t *testing.T) {
result := prepareRecordValue("A", `example`)
expected := []string{`example`}
if len(result) != len(expected) || result[0] != expected[0] {
t.Errorf("expected %v, got %v", expected, result)
}
}

0 comments on commit b29d8eb

Please sign in to comment.