Skip to content

Commit

Permalink
fixing Test file
Browse files Browse the repository at this point in the history
Signed-off-by: manisha kumari <[email protected]>
  • Loading branch information
ManishaKumari295 committed May 30, 2024
1 parent c9499f7 commit 5d71f84
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 432 deletions.
30 changes: 14 additions & 16 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package main

import (
"fmt"
corev2 "github.com/sensu/sensu-go/api/core/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"io"
"net/http"
"net/http/httptest"
"os"
"testing"

corev2 "github.com/sensu/sensu-go/api/core/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestFormattedEventAction(t *testing.T) {
Expand Down Expand Up @@ -123,17 +122,16 @@ func TestSendMessage(t *testing.T) {
}

func TestCheckArgs(t *testing.T) {
// Test case where webhook URL is missing
//event := &corev2.Event{}
assert := assert.New(t)
config := HandlerConfig{}
event := corev2.FixtureEvent("entity1", "check1")
err := checkArgs(event)
fmt.Println("ERR is", err)
assert.NotNil(t, err.Error())
assert.Equal(t, fmt.Sprintf("--%s or SLACK_WEBHOOK_URL environment variable is required", webHookURL), err.Error())

// Test case where webhook URL is provided
//config.slackwebHookURL = "http://example.com/webhook"
//err = checkArgs(event)
//assert.Nil(t, err)
config.slackDescriptionTemplate = "Sensu Event Details"
config.slackUsername = "Dummy user"
config.slackChannel = "Test"
config.slackIconURL = "https://www.sensu.io/img/sensu-logo.png"
config.slackwebHookURL = ""
assert.Error(checkArgs(event))
_ = os.Setenv("SLACK_WEBHOOK_URL", "http://example.com/webhook")
config.slackwebHookURL = os.Getenv("SLACK_WEBHOOK_URL")
assert.NoError(checkArgs(event))
}
207 changes: 0 additions & 207 deletions test/Hello_old.json

This file was deleted.

1 change: 0 additions & 1 deletion test/event.json

This file was deleted.

Loading

0 comments on commit 5d71f84

Please sign in to comment.