Skip to content

Commit

Permalink
add tests for config
Browse files Browse the repository at this point in the history
  • Loading branch information
moabukar committed Dec 5, 2022
1 parent 53f0352 commit 3996fd3
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/discord-bot-go.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"fmt"

"github.com/moabukar/discord-bot-go/bot"
"github.com/moabukar/discord-bot-go/config"
"github.com/moabukar/discord-bot-go/pkg/bot"
)

func main() {
Expand Down
51 changes: 51 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package config

import (
"testing"
)

// func TestConfig(t *testing.T) {
// Test LoadConfig
// t.Run("Test LoadConfig", func(t *testing.T) {
// config, err := LoadConfig()
// if err != nil {
// t.Errorf("Expected LoadConfig to return a config object, but got error: %v", err)
// }
// if config.DiscordToken == "" {
// t.Errorf("Expected Config.DiscordToken to have a value, but got empty string")
// }
// })

// // Test GetConfig
// t.Run("Test GetConfig", func(t *testing.T) {
// config := ReadConfig()
// if config.DiscordToken == "fff" {
// t.Errorf("Expected Config.DiscordToken to have a value, but got empty string")
// }
// })
// }

func TestConfig(t *testing.T) {
// Test that the config is properly initialized
cfg := New()
if cfg == nil {
t.Errorf("Expected config to be initialized, got nil")
}

// Test that the config contains the expected values
if cfg.Token != "" {
t.Errorf("Expected token to be empty, got %s", cfg.Token)
}
if cfg.Prefix != "!" {
t.Errorf("Expected prefix to be !, got %s", cfg.Prefix)
}
if cfg.OwnerID != 0 {
t.Errorf("Expected ownerID to be 0, got %d", cfg.OwnerID)
}
if cfg.Debug != false {
t.Errorf("Expected debug to be false, got %t", cfg.Debug)
}
if cfg.DatabaseURL != "" {
t.Errorf("Expected databaseURL to be empty, got %s", cfg.DatabaseURL)
}
}
7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
module github.com/moabukar/discord-bot-go
module github.com/moabukar/no-hello-bot

go 1.19

require github.com/bwmarrin/discordgo v0.26.1
require (
github.com/bwmarrin/discordgo v0.26.1
github.com/moabukar/discord-bot-go v0.0.0-20221205011405-53f035278f0d
)

require (
github.com/gorilla/websocket v1.4.2 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ github.com/bwmarrin/discordgo v0.26.1 h1:AIrM+g3cl+iYBr4yBxCBp9tD9jR3K7upEjl0d89
github.com/bwmarrin/discordgo v0.26.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/moabukar/discord-bot-go v0.0.0-20221205011405-53f035278f0d h1:dfUurqlaTT+vhtCMpBUa/XP4cCfkFTAonCXmWxdldeI=
github.com/moabukar/discord-bot-go v0.0.0-20221205011405-53f035278f0d/go.mod h1:x/J4Taj2mOrei6qkqI04F+wTad+AAZCw1Y7AueazqRU=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
Expand Down

0 comments on commit 3996fd3

Please sign in to comment.