41 lines
1022 B
Go
41 lines
1022 B
Go
package common_test
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
|
|
"src.opensuse.org/autogits/common"
|
|
)
|
|
|
|
func TestStatusRequestParsing(t *testing.T) {
|
|
t.Run("parsing repo creation message", func(t *testing.T) {
|
|
var h common.RequestHandler
|
|
|
|
h.StdLogger, h.ErrLogger = common.CreateStdoutLogger(os.Stdout, os.Stdout)
|
|
json, err := h.ParseStatusRequest(strings.NewReader(requestStatusJSON))
|
|
if err != nil {
|
|
t.Fatalf("Can't parse struct: %s", err)
|
|
}
|
|
|
|
if json.GetAction() != "pending" {
|
|
t.Fatalf("json.action is '%#v'", json)
|
|
}
|
|
|
|
if json.Repository.Full_Name != "autogits/nodejs-common" ||
|
|
json.Repository.Parent == nil ||
|
|
json.Repository.Parent.Parent != nil ||
|
|
len(json.Repository.Ssh_Url) < 10 ||
|
|
json.Repository.Default_Branch != "factory" ||
|
|
json.Repository.Object_Format_Name != "sha256" {
|
|
|
|
t.Fatalf("invalid repository parse: %#v", json.Repository)
|
|
}
|
|
|
|
if json.Sha != "e637d86cbbdd438edbf60148e28f9d75a74d51b27b01f75610f247cd18394c8e" {
|
|
t.Fatal("Invalid SHA:", json.Sha)
|
|
}
|
|
})
|
|
}
|
|
|