Skip to content

Commit

Permalink
Make sure always config is accessed through runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Dec 13, 2024
1 parent 3a0b0c8 commit 1bfa6ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions backends/rapidpro/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type BackendTestSuite struct {
b *backend
}

func testConfig() *runtime.Config {
func testRuntime() *runtime.Runtime {
config := runtime.NewDefaultConfig()
config.DB = "postgres://courier_test:temba@localhost:5432/courier_test?sslmode=disable"
config.Redis = "redis://localhost:6379/0"
Expand All @@ -58,7 +58,7 @@ func testConfig() *runtime.Config {
config.DynamoEndpoint = "http://localhost:6000"
config.DynamoTablePrefix = "Test"

return config
return &runtime.Runtime{Config: config}
}

func (ts *BackendTestSuite) SetupSuite() {
Expand All @@ -67,7 +67,7 @@ func (ts *BackendTestSuite) SetupSuite() {
// turn off logging
log.SetOutput(io.Discard)

b, err := courier.NewBackend(&runtime.Runtime{Config: testConfig()})
b, err := courier.NewBackend(testRuntime())
noError(err)

ts.b = b.(*backend)
Expand Down
16 changes: 8 additions & 8 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ import (
"github.com/stretchr/testify/require"
)

func testConfig() *runtime.Config {
func testRuntime() *runtime.Runtime {
config := runtime.NewDefaultConfig()
config.DB = "postgres://courier_test:temba@localhost:5432/courier_test?sslmode=disable"
config.Redis = "redis://localhost:6379/0"
config.Port = 8081
return config
return &runtime.Runtime{Config: config}
}

func TestServerURLs(t *testing.T) {
logger := slog.Default()
config := testConfig()
config.StatusUsername = "admin"
config.StatusPassword = "password123"
rt := testRuntime()
rt.Config.StatusUsername = "admin"
rt.Config.StatusPassword = "password123"

mb := test.NewMockBackend()
mb.AddChannel(test.NewMockChannel("95710b36-855d-4832-a723-5f71f73688a0", "MCK", "12345", "RW", []string{urns.Phone.Prefix}, nil))

server := courier.NewServerWithLogger(&runtime.Runtime{Config: config}, mb, logger)
server := courier.NewServerWithLogger(rt, mb, logger)
server.Start()
defer server.Stop()

Expand Down Expand Up @@ -84,7 +84,7 @@ func TestServerURLs(t *testing.T) {
func TestIncoming(t *testing.T) {
// create and start our backend and server
mb := test.NewMockBackend()
s := courier.NewServer(&runtime.Runtime{Config: testConfig()}, mb)
s := courier.NewServer(testRuntime(), mb)

s.Start()
defer s.Stop()
Expand Down Expand Up @@ -131,7 +131,7 @@ func TestOutgoing(t *testing.T) {

// create and start our backend and server
mb := test.NewMockBackend()
s := courier.NewServer(&runtime.Runtime{Config: testConfig()}, mb)
s := courier.NewServer(testRuntime(), mb)

s.Start()
defer s.Stop()
Expand Down

0 comments on commit 1bfa6ba

Please sign in to comment.