github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/packages/conan/conanfile_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  	name             = "ConanPackage"
    17  	version          = "1.2"
    18  	license          = "MIT"
    19  	author           = "GitBundle <info@gitbundle.com>"
    20  	homepage         = "https://gitbundle.com/"
    21  	url              = "https://gitbundle.com/"
    22  	description      = "Description of ConanPackage"
    23  	topic1           = "gitbundle"
    24  	topic2           = "conan"
    25  	contentConanfile = `from conans import ConanFile, CMake, tools
    26  
    27  class ConanPackageConan(ConanFile):
    28      name = "` + name + `"
    29      version = "` + version + `"
    30      license = "` + license + `"
    31      author = "` + author + `"
    32      homepage = "` + homepage + `"
    33      url = "` + url + `"
    34      description = "` + description + `"
    35      topics = ("` + topic1 + `", "` + topic2 + `")
    36      settings = "os", "compiler", "build_type", "arch"
    37      options = {"shared": [True, False], "fPIC": [True, False]}
    38      default_options = {"shared": False, "fPIC": True}
    39      generators = "cmake"
    40  `
    41  )
    42  
    43  func TestParseConanfile(t *testing.T) {
    44  	metadata, err := ParseConanfile(strings.NewReader(contentConanfile))
    45  	assert.Nil(t, err)
    46  	assert.Equal(t, license, metadata.License)
    47  	assert.Equal(t, author, metadata.Author)
    48  	assert.Equal(t, homepage, metadata.ProjectURL)
    49  	assert.Equal(t, url, metadata.RepositoryURL)
    50  	assert.Equal(t, description, metadata.Description)
    51  	assert.Equal(t, []string{topic1, topic2}, metadata.Keywords)
    52  }