dsn_test.go 520 B

1234567891011121314151617181920212223242526272829
  1. package dsn
  2. import (
  3. "testing"
  4. . "github.com/smartystreets/goconvey/convey"
  5. )
  6. func TestParseDSN(t *testing.T) {
  7. Convey("test parsedsn", t, func() {
  8. var (
  9. s = "key:secret@group/topic=1&role=2&color=red"
  10. t = &DSN{
  11. Key: "key",
  12. Secret: "secret",
  13. Group: "group",
  14. Topic: "1",
  15. Role: "2",
  16. Color: "red",
  17. }
  18. )
  19. d, err := ParseDSN(s)
  20. So(err, ShouldBeNil)
  21. So(d, ShouldResemble, t)
  22. s = "key:secret@group/top:ic=1&role=2"
  23. _, err = ParseDSN(s)
  24. So(err, ShouldNotBeNil)
  25. })
  26. }