github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/packages/conan/conaninfo_parser_test.go (about)

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