-
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.
handle error case for refUpdated event translation
Signed-off-by: Jalander Ramagiri <[email protected]>
- Loading branch information
Jalander Ramagiri
committed
Aug 9, 2024
1 parent
790cd85
commit 8ca1fb5
Showing
2 changed files
with
43 additions
and
40 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 |
---|---|---|
@@ -1,40 +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) | ||
} | ||
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