Files
autogits/common/request_push_test.go
Adam Majer f47da62481
All checks were successful
go-generate-check / go-generate-check (pull_request) Successful in 27s
common: replace legacy logger with standard impl
2026-01-31 10:18:14 +01:00

52 lines
1.5 KiB
Go

package common_test
/*
* This file is part of Autogits.
*
* Copyright © 2024 SUSE LLC
*
* Autogits is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 2 of the License, or (at your option) any later
* version.
*
* Autogits is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
import (
"strings"
"testing"
"src.opensuse.org/autogits/common"
)
func TestPushRequestParsing(t *testing.T) {
common.SetTestLogger(t)
t.Run("parsing repo creation message", func(t *testing.T) {
var h common.RequestHandler
json, err := h.ParsePushRequest(strings.NewReader(examplePushJSON))
if err != nil {
t.Fatalf("failed to parser push request: %v", err)
}
if json.Total_Commits < 1 || json.Total_Commits != len(json.Commits) {
t.Fatalf("push without commits? '%#v'", json)
}
if json.Repository.Full_Name != "autogits/_ObsPrj" ||
json.Repository.Parent != nil ||
len(json.Repository.Ssh_Url) < 10 ||
json.Repository.Default_Branch != "main" ||
json.Repository.Object_Format_Name != "sha256" {
t.Fatalf("invalid repository parse: %#v", json.Repository)
}
})
}