debian-forge-composer/internal/client/integration_test.go
Ondřej Budai 0359647a82 go.mod: update to Go 1.18
Fedora 35 support was dropped, so we can update to a newer Go.

Stable RHEL 8 and 9 and Fedora 36 ships Go 1.18, so let's switch to it.

"//go:build" directives are now apparently enforced by go fmt, so that's why
there were added.

Also, all the github actions were adjusted to use Go 1.18.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
2023-01-09 14:03:18 +01:00

54 lines
1.1 KiB
Go

// Package client - integration_test contains functions to setup integration tests
// Copyright (C) 2020 by Red Hat, Inc.
//go:build integration
// +build integration
package client
import (
"fmt"
"os"
"testing"
"github.com/osbuild/osbuild-composer/internal/test"
)
// Hold test state to share between tests
var testState *TestState
// Setup the socket to use for running the tests
// Also makes sure there is a running server to test against
func executeTests(m *testing.M) int {
var err error
testState, err = setUpTestState("/run/weldr/api.socket", "qcow2", false)
if err != nil {
fmt.Printf("ERROR: Test setup failed: %s\n", err)
panic(err)
}
// Setup the test repo
dir, err := test.SetUpTemporaryRepository()
if err != nil {
fmt.Printf("ERROR: Test repo setup failed: %s\n", err)
panic(err)
}
// Cleanup after the tests
defer func() {
err := test.TearDownTemporaryRepository(dir)
if err != nil {
fmt.Printf("ERROR: Failed to clean up temporary repository: %s\n", err)
}
}()
testState.repoDir = dir
// Run the tests
return m.Run()
}
func TestMain(m *testing.M) {
os.Exit(executeTests(m))
}