Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
fix: change env name at exchange block
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitryburov committed Mar 4, 2023
1 parent 3236356 commit 25347d8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
5 changes: 2 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ type LoggerConfig struct {
// ExchangeConfig for exchange configuration
type ExchangeConfig struct {
Url string `env:"URL,required"`
Origin string `env:"URL,required"`
Protocol string `env:"URL,default="`
Origin string `env:"ORIGIN,required"`
Protocol string `env:"PROTOCOL,default="`
Symbols []string `env:"SYMBOLS,required"`
Channels []string `env:"CHANNELS,required"`
}
Expand All @@ -45,5 +45,4 @@ func NewConfig(ctx context.Context) (*Config, error) {
}

return &cfg, nil

}
54 changes: 54 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package config

import (
"context"
"reflect"
"testing"
)

func TestNewConfig(t *testing.T) {
type args struct {
ctx context.Context
}

tests := []struct {
name string
args args
want *Config
wantErr bool
}{
{name: testing.CoverMode(), args: args{ctx: context.Background()}, want: &Config{
Exchange: ExchangeConfig{
Url: "wss://ws-feed.exchange.coinbase.com",
Origin: "https://coinbase.com",
Protocol: "",
Symbols: []string{"ETH-BTC", "BTC-USD", "BTC-EUR"},
Channels: []string{"ticker"},
},
Database: DatabaseConfig{
Host: "localhost:3306",
User: "test_mysql",
Password: "a2s_kjlasjd",
Base: "test",
},
Logger: LoggerConfig{
DisableCaller: false,
DisableStacktrace: true,
Level: "debug",
},
}, wantErr: false},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := NewConfig(tt.args.ctx)
if (err != nil) != tt.wantErr {
t.Errorf("NewConfig() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewConfig() got = %v, want %v", got, tt.want)
}
})
}
}

0 comments on commit 25347d8

Please sign in to comment.