summaryrefslogtreecommitdiffstats
path: root/modules/packages/conan/conaninfo_parser_test.go
blob: dfb1836474a2b02821f9905d63078683f87c471d (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package conan

import (
	"strings"
	"testing"

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

const (
	settingsKey   = "arch"
	settingsValue = "x84_64"
	optionsKey    = "shared"
	optionsValue  = "False"
	requires      = "fmt/7.1.3"
	hash          = "74714915a51073acb548ca1ce29afbac"
	envKey        = "CC"
	envValue      = "gcc-10"

	contentConaninfo = `[settings]
    ` + settingsKey + `=` + settingsValue + `

[requires]
    ` + requires + `

[options]
    ` + optionsKey + `=` + optionsValue + `

[full_settings]
    ` + settingsKey + `=` + settingsValue + `

[full_requires]
    ` + requires + `

[full_options]
    ` + optionsKey + `=` + optionsValue + `

[recipe_hash]
    ` + hash + `

[env]
` + envKey + `=` + envValue + `

`
)

func TestParseConaninfo(t *testing.T) {
	info, err := ParseConaninfo(strings.NewReader(contentConaninfo))
	assert.NotNil(t, info)
	require.NoError(t, err)
	assert.Equal(
		t,
		map[string]string{
			settingsKey: settingsValue,
		},
		info.Settings,
	)
	assert.Equal(t, info.Settings, info.FullSettings)
	assert.Equal(
		t,
		map[string]string{
			optionsKey: optionsValue,
		},
		info.Options,
	)
	assert.Equal(t, info.Options, info.FullOptions)
	assert.Equal(
		t,
		[]string{requires},
		info.Requires,
	)
	assert.Equal(t, info.Requires, info.FullRequires)
	assert.Equal(t, hash, info.RecipeHash)
	assert.Equal(
		t,
		map[string][]string{
			envKey: {envValue},
		},
		info.Environment,
	)
}