package decoder_test import ( "io" "strings" "testing" "dnsupdater/ip/resolver/decoder" "github.com/stretchr/testify/assert" ) func TestService_Name(t *testing.T) { tests := []struct { name string input string expected string expectError error }{ { name: "simple", input: "192.168.0.1", expected: "192.168.0.1", expectError: io.EOF, }, { name: "whitespace", input: " 192.168.0.1 ", expected: "192.168.0.1", expectError: io.EOF, }, { name: "newline", input: "192.168.0.1\r\nmore stuff", expected: "192.168.0.1", }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { ip, err := decoder.Text(strings.NewReader(test.input)) assert.ErrorIs(t, err, test.expectError) assert.Equal(t, test.expected, ip) }) } }