Skip to content

Commit

Permalink
Fix testing by adding secrets and removing init()
Browse files Browse the repository at this point in the history
  • Loading branch information
chilipizdrick committed Mar 10, 2024
1 parent 09dadb3 commit d163a2d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: go build -v ./...

- name: Test
run: go test -v ./...
run: TESTING_CLIENT_TOKEN=${{ secrets.TESTING_CLIENT_TOKEN }} TESTING_CLIENT_ID=${{ secrets.TESTING_CLIENT_ID }} TESTING_GUILD_ID=${{ secrets.TESTING_GUILD_ID }} go test -v ./...

build-and-deploy-to-dockerhub:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion basic_functionality_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

func TestBasicFunctionality(t *testing.T) {

// Load env. variables
// Load and check for env. variables
err := godotenv.Load(".env")
if err != nil {
log.Println("[INFO] No .env file found.")
Expand Down
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ type SessionWrapper struct {
*discord.Session
}

func init() {
func main() {
// Load and check for env. variables
err := godotenv.Load(".env")
if err != nil {
log.Println("[INFO] No .env file found.")
Expand All @@ -33,9 +34,7 @@ func init() {
if os.Getenv("CLIENT_ID") == "" {
log.Fatalln("[FATAL] CLIENT_ID env. variable not specified.")
}
}

func main() {
// Initialise new discord bot session
s := SessionWrapper{initNewDiscordSession(os.Getenv("CLIENT_TOKEN"))}

Expand Down

0 comments on commit d163a2d

Please sign in to comment.