(t *testing.T)
| 1878 | } |
| 1879 | |
| 1880 | func TestValidateSubject(t *testing.T) { |
| 1881 | tests := []struct { |
| 1882 | name string |
| 1883 | subject string |
| 1884 | wantErr bool |
| 1885 | }{ |
| 1886 | {"valid short", "foo", false}, |
| 1887 | {"valid with dots", "foo.bar.baz", false}, |
| 1888 | {"valid long", "metrics.production.server01.cpu.usage.percent", false}, |
| 1889 | {"empty string", "", true}, |
| 1890 | {"contains space", "foo bar", true}, |
| 1891 | {"contains tab", "foo\tbar", true}, |
| 1892 | {"contains CR", "foo\rbar", true}, |
| 1893 | {"contains LF", "foo\nbar", true}, |
| 1894 | {"space at start", " foo", true}, |
| 1895 | {"space at end", "foo ", true}, |
| 1896 | {"tab at start", "\tfoo", true}, |
| 1897 | {"newline at end", "foo\n", true}, |
| 1898 | {"valid with wildcards", "foo.*.bar.>", false}, |
| 1899 | {"valid with hyphen", "foo-bar-baz", false}, |
| 1900 | {"valid with underscore", "foo_bar_baz", false}, |
| 1901 | } |
| 1902 | |
| 1903 | for _, tt := range tests { |
| 1904 | t.Run(tt.name, func(t *testing.T) { |
| 1905 | err := validateSubject(tt.subject) |
| 1906 | if tt.wantErr { |
| 1907 | if !errors.Is(err, ErrBadSubject) { |
| 1908 | t.Errorf("validateSubject(%q) error = %v, want ErrBadSubject", tt.subject, err) |
| 1909 | } |
| 1910 | return |
| 1911 | } |
| 1912 | if err != nil { |
| 1913 | t.Errorf("validateSubject(%q) unexpected error: %v", tt.subject, err) |
| 1914 | } |
| 1915 | }) |
| 1916 | } |
| 1917 | } |
| 1918 | |
| 1919 | func TestWriteBufferSize(t *testing.T) { |
| 1920 | opts := GetDefaultOptions() |
nothing calls this directly
no test coverage detected