File: osarch_test.go

package info (click to toggle)
distrobuilder 3.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,468 kB
  • sloc: sh: 204; makefile: 75
file content (55 lines) | stat: -rw-r--r-- 854 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package shared

import (
	"log"
	"testing"

	"github.com/stretchr/testify/require"
)

func TestGetArch(t *testing.T) {
	tests := []struct {
		distro   string
		arch     string
		expected string
	}{
		{
			"alpinelinux",
			"x86_64",
			"x86_64",
		},
		{
			"centos",
			"x86_64",
			"x86_64",
		},
		{
			"debian",
			"amd64",
			"amd64",
		},
		{
			"debian",
			"x86_64",
			"amd64",
		},
		{
			"debian",
			"s390x",
			"s390x",
		},
	}

	for i, tt := range tests {
		log.Printf("Running test #%d: %s %s", i, tt.distro, tt.arch)
		arch, err := GetArch(tt.distro, tt.arch)
		require.NoError(t, err)
		require.Equal(t, tt.expected, arch)
	}

	_, err := GetArch("distro", "")
	require.EqualError(t, err, "Architecture map isn't supported: distro")

	_, err = GetArch("debian", "arch")
	require.EqualError(t, err, "Architecture isn't supported: arch")
}