Skip to content

Commit

Permalink
Update setup-go action, fix assertion in e2e tests (#1375)
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok authored Feb 9, 2024
1 parent 897f001 commit 865191b
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-go-mod-private/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ runs:
using: "composite"
steps:
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: './test/go.mod'
cache: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/branch-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
Expand Down Expand Up @@ -215,7 +215,7 @@ jobs:
install-only: true
version: latest
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
# When the files to be extracted are already present,
Expand All @@ -76,7 +76,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
Expand All @@ -94,7 +94,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
persist-credentials: false

- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
Expand Down Expand Up @@ -205,7 +205,7 @@ jobs:
persist-credentials: false

- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: git fetch --force --tags

- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upload-plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
Expand Down
26 changes: 3 additions & 23 deletions test/cloud-slack-dev-e2e/cloud_slack_dev_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ import (
stringsutil "k8s.io/utils/strings"

gqlModel "github.com/kubeshop/botkube-cloud/botkube-cloud-backend/pkg/graphql"
"github.com/kubeshop/botkube/pkg/api"
"github.com/kubeshop/botkube/pkg/bot/interactive"
"github.com/kubeshop/botkube/pkg/formatx"
)

Expand Down Expand Up @@ -380,16 +378,13 @@ func TestCloudSlackE2E(t *testing.T) {

t.Log("Testing ping for not connected deployment #2")
command = "ping"
expectedBlockMessage := notConnectedMessage(deployment2.Name, deployment2.ID)
expectedMessage = fmt.Sprintf("The cluster %s (id: %s) is not connected.", deployment2.Name, deployment2.ID)
tester.PostMessageToBot(t, channel.Identifier(), fmt.Sprintf("%s --cluster-name %s", command, deployment2.Name))

renderedMsg := interactive.RenderMessage(tester.MDFormatter(), expectedBlockMessage)
renderedMsg = strings.Replace(renderedMsg, "\n", " ", -1)
renderedMsg = strings.TrimSuffix(renderedMsg, " ")
err = tester.WaitForLastInteractiveMessagePostedEqualWithCustomRender(tester.BotUserID(), channel.ID(), renderedMsg)
err = tester.WaitForLastMessageContains(tester.BotUserID(), channel.ID(), expectedMessage)
if err != nil { // the new cloud backend not release yet
t.Logf("Fallback to the old behavior with message sent at the channel level...")
err = tester.OnChannel().WaitForLastInteractiveMessagePostedEqualWithCustomRender(tester.BotUserID(), channel.ID(), renderedMsg)
err = tester.OnChannel().WaitForLastMessageContains(tester.BotUserID(), channel.ID(), expectedMessage)
}
require.NoError(t, err)

Expand Down Expand Up @@ -725,21 +720,6 @@ func createK8sCli(t *testing.T, kubeconfigPath string) *kubernetes.Clientset {
return k8sCli
}

func notConnectedMessage(name, id string) interactive.CoreMessage {
return interactive.CoreMessage{
Message: api.Message{
Sections: []api.Section{
{
Base: api.Base{
Header: "Instance not connected",
Description: fmt.Sprintf("The cluster %s (id: %s) is not connected.", name, id),
},
},
},
},
}
}

func closePage(t *testing.T, name string, page *rod.Page) {
t.Helper()
err := page.Close()
Expand Down
8 changes: 0 additions & 8 deletions test/commplatform/discord_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ func (d *DiscordTester) ThirdChannel() Channel {
return d.thirdChannel
}

func (d *DiscordTester) MDFormatter() interactive.MDFormatter {
return d.mdFormatter
}

func (d *DiscordTester) InitUsers(t *testing.T) {
t.Helper()

Expand Down Expand Up @@ -415,10 +411,6 @@ func (d *DiscordTester) WaitForLastInteractiveMessagePostedEqual(userID, channel
return d.WaitForMessagePosted(userID, channelID, 1, d.AssertEquals(markdown))
}

func (d *DiscordTester) WaitForLastInteractiveMessagePostedEqualWithCustomRender(userID, channelID string, renderedMsg string) error {
return d.WaitForMessagePosted(userID, channelID, 1, d.AssertEquals(renderedMsg))
}

func (d *DiscordTester) SetTimeout(timeout time.Duration) {
d.cfg.MessageWaitTimeout = timeout
}
Expand Down
2 changes: 0 additions & 2 deletions test/commplatform/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ type BotDriver interface {
BotName() string
BotUserID() string
TesterUserID() string
MDFormatter() interactive.MDFormatter
WaitForInteractiveMessagePostedRecentlyEqual(userID string, channelID string, message interactive.CoreMessage) error
WaitForLastInteractiveMessagePostedEqual(userID string, channelID string, message interactive.CoreMessage) error
WaitForLastInteractiveMessagePostedEqualWithCustomRender(userID, channelID string, renderedMsg string) error
SetTimeout(timeout time.Duration)
Timeout() time.Duration
ReplaceBotNamePlaceholder(msg *interactive.CoreMessage, clusterName string)
Expand Down
7 changes: 0 additions & 7 deletions test/commplatform/slack_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ func (s *SlackTester) ThirdChannel() Channel {
return s.thirdChannel
}

func (s *SlackTester) MDFormatter() interactive.MDFormatter {
return s.mdFormatter
}

func (s *SlackTester) PostInitialMessage(t *testing.T, channelName string) {
t.Helper()
t.Log("Posting welcome message...")
Expand Down Expand Up @@ -467,9 +463,6 @@ func (s *SlackTester) WaitForLastInteractiveMessagePostedEqual(userID, channelID
return s.WaitForInteractiveMessagePosted(userID, channelID, 1, s.AssertEquals(printedBlocks))
}

func (s *SlackTester) WaitForLastInteractiveMessagePostedEqualWithCustomRender(userID, channelID string, renderedMsg string) error {
return s.WaitForMessagePosted(userID, channelID, 1, s.AssertEquals(renderedMsg))
}

func (s *SlackTester) SetTimeout(timeout time.Duration) {
s.cfg.MessageWaitTimeout = timeout
Expand Down
8 changes: 0 additions & 8 deletions test/commplatform/teams_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ func (s *TeamsTester) ThirdChannel() Channel {
return s.thirdChannel
}

func (s *TeamsTester) MDFormatter() interactive.MDFormatter {
return s.renderer.MDFormatter()
}

func (s *TeamsTester) PostInitialMessage(t *testing.T, channelName string) {
t.Helper()
t.Log("Posting welcome message...")
Expand Down Expand Up @@ -343,10 +339,6 @@ func (s *TeamsTester) WaitForLastInteractiveMessagePostedEqual(userID, channelID
return s.waitForAdaptiveCardMessage(userID, channelID, 1, msg)
}

func (s *TeamsTester) WaitForLastInteractiveMessagePostedEqualWithCustomRender(_, _, _ string) error {
return errors.New("not implemented")
}

func (s *TeamsTester) WaitForMessagePostedWithFileUpload(_, _ string, _ FileUploadAssertion) error {
return errors.New("not implemented")
}
Expand Down

0 comments on commit 865191b

Please sign in to comment.