Commit 1311501d authored by Boris Mühmer's avatar Boris Mühmer
Browse files

added missing function to improve coverage and unit tests

parent aa5f2a79
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -18,16 +18,24 @@ const (
	Err
)

const (
	textChannelIn          = "In"
	textChannelOut         = "Out"
	textChannelErr         = "Err"
	textChannelUndefined   = "Undefined"
	formatChannelUndefined = "unknown channel %d"
)

func (c Channel) String() string {
	switch c {
	case In:
		return "In"
		return textChannelIn
	case Out:
		return "Out"
		return textChannelOut
	case Err:
		return "Err"
		return textChannelErr
	default:
		return fmt.Sprintf("unknown channel %d", uint(c))
		return fmt.Sprintf(formatChannelUndefined, uint(c))
	}
}

+18 −0
Original line number Diff line number Diff line
package get

import (
	"fmt"
	"testing"

	"repositories.muehmer.net/bsmrgo/get/mock/passwd"
)

func TestChannelStrings(t *testing.T) {
	uc := 99
	for _, c := range []struct {
		c Channel
		s string
	}{
		{c: In, s: textChannelIn},
		{c: Out, s: textChannelOut},
		{c: Err, s: textChannelErr},
		{c: Channel(uc), s: fmt.Sprintf(formatChannelUndefined, uc)},
	} {
		if s := c.c.String(); s != c.s {
			t.Errorf("String() is %q, expected %q", s, c.s)
		}
	}
}

const (
	lp1User = "user1"
	lp1Pass = "pass1"