-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding test cases for project related events
Signed-off-by: Jalander Ramagiri <[email protected]>
- Loading branch information
Jalander Ramagiri
committed
Jul 5, 2024
1 parent
f783f4c
commit 790cd85
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package gerrit | ||
|
||
import ( | ||
"net/http" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestHandleTranslateProjectCreatedEvent(t *testing.T) { | ||
event, err := os.ReadFile("testdata/project-created.json") | ||
if err != nil { | ||
t.Fatalf("Failed to read project-created.json file: %v", err) | ||
} | ||
headers := http.Header{} | ||
headers.Set("X-Origin-Url", "http://gerrit.est.tech") | ||
|
||
cdEvent, err := HandleTranslateGerritEvent(string(event), headers) | ||
if err != nil { | ||
t.Errorf("Expected RepositoryCreated CDEvent to be successful.") | ||
return | ||
} | ||
Log().Info("Handle project-created gerrit event into dev.cdevents.repository.created is successful ", cdEvent) | ||
} | ||
|
||
func TestHandleTranslateProjectHeadUpdatedEvent(t *testing.T) { | ||
|
||
event, err := os.ReadFile("testdata/project-head-updated.json") | ||
if err != nil { | ||
t.Fatalf("Failed to read project-head-updated.json file: %v", err) | ||
} | ||
headers := http.Header{} | ||
headers.Set("X-Origin-Url", "http://gerrit.est.tech") | ||
|
||
cdEvent, err := HandleTranslateGerritEvent(string(event), headers) | ||
if err != nil { | ||
t.Errorf("Expected RepositoryModified CDEvent to be successful.") | ||
return | ||
} | ||
Log().Info("Handle project-head-updated gerrit event into dev.cdevents.repository.modified is successful ", cdEvent) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"projectName": "TestRepo3", | ||
"headName": "refs/heads/master", | ||
"type": "project-created", | ||
"eventCreatedOn": 1700131789 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"projectName": "TestRepo3", | ||
"oldHead": "refs/heads/master", | ||
"newHead": "refs/heads/main", | ||
"type": "project-head-updated", | ||
"eventCreatedOn": 1700148011 | ||
} |