(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestNewMongoFactory(t *testing.T) { |
| 13 | t.Parallel() |
| 14 | for _, c := range []struct { |
| 15 | name string |
| 16 | reloadable bool |
| 17 | }{ |
| 18 | { |
| 19 | "reload", true, |
| 20 | }, |
| 21 | { |
| 22 | "not reload", false, |
| 23 | }, |
| 24 | } { |
| 25 | dispatcher := &events.SyncDispatcher{} |
| 26 | factory, cleanup := provideMongoFactory(&providersOption{ |
| 27 | reloadable: c.reloadable, |
| 28 | })(factoryIn{ |
| 29 | In: dig.In{}, |
| 30 | Conf: config.MapAdapter{"mongo": map[string]struct { |
| 31 | URI string `json:"uri"` |
| 32 | }{ |
| 33 | "default": { |
| 34 | URI: "mongodb://127.0.0.1:27017", |
| 35 | }, |
| 36 | "alternative": { |
| 37 | URI: "mongodb://127.0.0.1:27017", |
| 38 | }, |
| 39 | }}, |
| 40 | Tracer: nil, |
| 41 | Dispatcher: dispatcher, |
| 42 | }) |
| 43 | def, err := factory.Make("default") |
| 44 | assert.NoError(t, err) |
| 45 | assert.NotNil(t, def) |
| 46 | alt, err := factory.Make("alternative") |
| 47 | assert.NoError(t, err) |
| 48 | assert.NotNil(t, alt) |
| 49 | assert.NotNil(t, cleanup) |
| 50 | assert.Equal(t, c.reloadable, dispatcher.ListenerCount(events.OnReload) == 1) |
| 51 | cleanup() |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | func TestProvideConfigs(t *testing.T) { |
| 56 | c := provideConfig() |
nothing calls this directly
no test coverage detected