55 lines
1.7 KiB
Go
55 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"path/filepath"
|
|
"runtime"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestMultipleChannelAndSignedArtifacts(t *testing.T) {
|
|
s := testServer(t)
|
|
p := project(t, s)
|
|
paths := []string{"app/build/outputs/apk/uiui/debug/app.apk", "app/build/outputs/apk/uiuios/debug/app.apk", "app/build/outputs/apk/uiui/debug/app-signed.apk"}
|
|
wrapper := "#!/bin/sh\n"
|
|
name := "gradlew"
|
|
if runtime.GOOS == "windows" {
|
|
wrapper = "@echo off\r\n"
|
|
name = "gradlew.bat"
|
|
}
|
|
for i, path := range paths {
|
|
dir := filepath.ToSlash(filepath.Dir(path))
|
|
if runtime.GOOS == "windows" {
|
|
wrapper += "mkdir " + strings.ReplaceAll(dir, "/", `\`) + " 2>nul\r\necho artifact" + string(rune('0'+i)) + ">" + strings.ReplaceAll(path, "/", `\`) + "\r\n"
|
|
} else {
|
|
wrapper += "mkdir -p " + dir + "\nprintf artifact" + string(rune('0'+i)) + " > " + path + "\n"
|
|
}
|
|
}
|
|
if runtime.GOOS == "windows" {
|
|
wrapper += "echo signature>app\\build\\outputs\\apk\\uiui\\debug\\app.apk.idsig\r\nexit /b 0\r\n"
|
|
} else {
|
|
wrapper += "printf signature > app/build/outputs/apk/uiui/debug/app.apk.idsig\n"
|
|
}
|
|
writeFixture(t, filepath.Join(s.work(p), name), wrapper)
|
|
b := &Build{ID: id(), Project: p, Status: "queued", Task: ":app:assembleDebug"}
|
|
s.builds[b.ID] = b
|
|
s.projects[p].Busy = true
|
|
s.run(b)
|
|
if b.Status != "success" || len(b.Artifacts) != 3 {
|
|
t.Fatalf("%s %v %v", b.Status, b.Artifacts, b.Logs)
|
|
}
|
|
seen := map[string]bool{}
|
|
for _, a := range b.Artifacts {
|
|
seen[a.SourcePath] = true
|
|
response := call(t, s, "GET", "/builds/"+b.ID+"/artifacts/"+a.Name, nil)
|
|
if response.Code != 200 || digest(response.Body.Bytes()) != a.Hash {
|
|
t.Fatal("artifact content mismatch", a)
|
|
}
|
|
}
|
|
for _, path := range paths {
|
|
if !seen[path] {
|
|
t.Fatal("missing artifact provenance", path)
|
|
}
|
|
}
|
|
}
|