Skip to content

Commit

Permalink
Fix webhook tests and reformat payload info
Browse files Browse the repository at this point in the history
Co-authored-by: Till-André Diegeler<[email protected]>
Pushed-by: Till-André Diegeler<[email protected]>
Signed-off-by: Till-André Diegeler<[email protected]>
  • Loading branch information
TiDgCloudogu committed Nov 28, 2024
1 parent 18acb89 commit b828dab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions testdata/webhook/scm-webhook-data.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"HTMLURL": "github.com/scm-manager/argocd-test",
"Branch": {
"Name": "testrepo",
"DefaultBranch": true
"sourceUrl": "https://scm-manager.org/scm/scm-manager/argocd-test",
"branch": {
"name": "develop",
"defaultBranch": true
}
}
4 changes: 2 additions & 2 deletions webhook_payloads.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package goscm

type PushEventPayload struct {
HTMLURL string `json:"HTMLURL"`
Branch Branch `json:"branch"`
SourceUrl string `json:"sourceUrl"`
Branch Branch `json:"branch"`
}
7 changes: 4 additions & 3 deletions webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package goscm

import (
"bytes"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"io"
"net/http"
Expand All @@ -27,7 +28,7 @@ func TestWebhook_Parse(t *testing.T) {
plPush, err := hook.Parse(req, PushEvent)
require.NoError(t, err, "Error while parsing hook information in Goscm.")

UNUSED(plPush)
assert.Equal(t, "https://scm-manager.org/scm/scm-manager/argocd-test", plPush.(PushEventPayload).SourceUrl)
assert.Equal(t, "develop", plPush.(PushEventPayload).Branch.Name)
assert.True(t, plPush.(PushEventPayload).Branch.DefaultBranch)
}

func UNUSED(x ...interface{}) {}

0 comments on commit b828dab

Please sign in to comment.