MCPcopy Create free account
hub / github.com/facebook/time / TestChannel

Function TestChannel

calnex/api/api_test.go:36–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34)
35
36func TestChannel(t *testing.T) {
37 legitChannelNamesToChannel := map[string]Channel{
38 "1": ChannelONE,
39 "2": ChannelTWO,
40 "C": ChannelC,
41 "D": ChannelD,
42 "VP1": ChannelVP1,
43 }
44 for channelS, channel := range legitChannelNamesToChannel {
45 c, err := ChannelFromString(channelS)
46 require.NoError(t, err)
47 require.Equal(t, channel, *c)
48
49 c = new(Channel)
50 err = c.UnmarshalText([]byte(channelS))
51 require.NoError(t, err)
52 require.Equal(t, channel, *c)
53 }
54
55 wrongChannelNames := []string{"", "?", "z", "foo"}
56 for _, channelS := range wrongChannelNames {
57 c, err := ChannelFromString(channelS)
58 require.Nil(t, c)
59 require.ErrorIs(t, ErrBadChannel, err)
60
61 c = new(Channel)
62 err = c.UnmarshalText([]byte(channelS))
63 require.ErrorIs(t, ErrBadChannel, err)
64 }
65}
66
67func TestChannels(t *testing.T) {
68 cs := Channels{}

Callers

nothing calls this directly

Calls 2

ChannelFromStringFunction · 0.85
UnmarshalTextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…