...
1
2
3
4
5
6
7 package readpref
8
9 import (
10 "testing"
11
12 "go.mongodb.org/mongo-driver/internal/assert"
13 )
14
15 func TestMode_String(t *testing.T) {
16 t.Parallel()
17
18 testCases := []struct {
19 name string
20 mode Mode
21 }{
22 {"primary", PrimaryMode},
23 {"primaryPreferred", PrimaryPreferredMode},
24 {"secondary", SecondaryMode},
25 {"secondaryPreferred", SecondaryPreferredMode},
26 {"nearest", NearestMode},
27 {"unknown", Mode(42)},
28 }
29
30 for _, tc := range testCases {
31 t.Run(tc.name, func(t *testing.T) {
32 assert.Equal(t, tc.name, tc.mode.String(), "expected %q, got %q", tc.name, tc.mode.String())
33 })
34 }
35 }
36
View as plain text