loading up the forgejo repo on tangled to test page performance
1// Copyright 2022 The Gitea Authors. All rights reserved.
2// SPDX-License-Identifier: MIT
3
4package conan
5
6import (
7 "strings"
8 "testing"
9
10 "github.com/stretchr/testify/assert"
11 "github.com/stretchr/testify/require"
12)
13
14const (
15 settingsKey = "arch"
16 settingsValue = "x84_64"
17 optionsKey = "shared"
18 optionsValue = "False"
19 requires = "fmt/7.1.3"
20 hash = "74714915a51073acb548ca1ce29afbac"
21 envKey = "CC"
22 envValue = "gcc-10"
23
24 contentConaninfo = `[settings]
25 ` + settingsKey + `=` + settingsValue + `
26
27[requires]
28 ` + requires + `
29
30[options]
31 ` + optionsKey + `=` + optionsValue + `
32
33[full_settings]
34 ` + settingsKey + `=` + settingsValue + `
35
36[full_requires]
37 ` + requires + `
38
39[full_options]
40 ` + optionsKey + `=` + optionsValue + `
41
42[recipe_hash]
43 ` + hash + `
44
45[env]
46` + envKey + `=` + envValue + `
47
48`
49)
50
51func TestParseConaninfo(t *testing.T) {
52 info, err := ParseConaninfo(strings.NewReader(contentConaninfo))
53 assert.NotNil(t, info)
54 require.NoError(t, err)
55 assert.Equal(
56 t,
57 map[string]string{
58 settingsKey: settingsValue,
59 },
60 info.Settings,
61 )
62 assert.Equal(t, info.Settings, info.FullSettings)
63 assert.Equal(
64 t,
65 map[string]string{
66 optionsKey: optionsValue,
67 },
68 info.Options,
69 )
70 assert.Equal(t, info.Options, info.FullOptions)
71 assert.Equal(
72 t,
73 []string{requires},
74 info.Requires,
75 )
76 assert.Equal(t, info.Requires, info.FullRequires)
77 assert.Equal(t, hash, info.RecipeHash)
78 assert.Equal(
79 t,
80 map[string][]string{
81 envKey: {envValue},
82 },
83 info.Environment,
84 )
85}