package config import ( "github.com/stretchr/testify/assert" "testing" "time" ) func TestNewConfig(t *testing.T) { tests := []struct { name string args string withError bool want any }{ { name: "equal", args: "test.env", want: &Config{ TelegramToken: "6016088135:AAH3KFBfsi5ivoS0bF9f0p6j28HNuwoBNn0", TelegramChannelID: -1001957127019, TemplatePath: "assets/template_msg.txt", HttpRateLimit: 30 * time.Second, HttpAddress: ":80", }, }, { name: "error no file", args: "not-found.env", withError: true, want: "open no-test.env: The system cannot find the file specified.", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got, err := NewConfig(tt.args) if tt.withError { assert.Equal(t, err.Error(), tt.want) } else { if assert.NoError(t, err) { assert.Equal(t, tt.want, got) } } }) } }