package common
/*
* 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 .
*/
import (
"testing"
)
func TestParseProjectMeta(t *testing.T) {
res, err := parseProjectMeta([]byte(metaPrjData))
if err != nil {
t.Fatal(err)
}
if len(res.BuildFlags.Contents) < 1 {
t.Fatalf("Build flags are not as expected")
}
}
func TestParsingOfBuildResults(t *testing.T) {
res, err := parseBuildResults([]byte(buildResultData))
if err != nil {
t.Fatal(err)
}
if res.Result[0].Project != "home:adamm" ||
res.Result[0].Status[1].Details != "nothing provides libBox2D-devel" ||
res.Result[0].Status[0].Code != "excluded" {
t.Fatal(res.Result)
}
if res.Result[0].Binaries[0].Package != "Nudoku" ||
len(res.Result[0].Binaries[0].Binary) != 0 {
t.Fatal(res.Result[0].Binaries[0])
}
}
func TestParsingRequestResults(t *testing.T) {
res, err := parseRequestXml([]byte(metaRequestData))
if err != nil {
t.Fatal(err)
}
if res.Id != 42 ||
res.Action.Source.Project != "home:foo-user" ||
res.Action.Source.Package != "obs-server" ||
*res.Action.Source.Revision != "521e" ||
res.Action.Target.Project != "OBS:Unstable" ||
res.Action.Target.Revision != nil {
t.Fatal(res)
}
}
const metaRequestData = `
cleanup
allright
Request created
Please review sources
A little version update
`
const metaPrjData = `
Adam's Home Projects
x86_64
aarch64
aarch64
aarch64
`
const buildResultData = `
nothing provides libBox2D-devel
nothing provides libBox2D-devel
conflict in file _service
no source uploaded
nothing provides libBox2D-devel
nothing provides libBox2D-devel
conflict in file _service
no source uploaded
conflict in file _service
no source uploaded
conflict in file _service
have choice for /usr/bin/openssl needed by opendkim: libressl openssl-1_0_0 openssl-3
no source uploaded
`