gitea源码

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2022 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package conan
  4. import (
  5. "strings"
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. const (
  10. name = "ConanPackage"
  11. version = "1.2"
  12. license = "MIT"
  13. author = "Gitea <info@gitea.io>"
  14. homepage = "https://gitea.io/"
  15. url = "https://gitea.com/"
  16. description = "Description of ConanPackage"
  17. topic1 = "gitea"
  18. topic2 = "conan"
  19. contentConanfile = `from conans import ConanFile, CMake, tools
  20. class ConanPackageConan(ConanFile):
  21. name = "` + name + `"
  22. version = "` + version + `"
  23. license = "` + license + `"
  24. author = "` + author + `"
  25. homepage = "` + homepage + `"
  26. url = "` + url + `"
  27. description = "` + description + `"
  28. topics = ("` + topic1 + `", "` + topic2 + `")
  29. settings = "os", "compiler", "build_type", "arch"
  30. options = {"shared": [True, False], "fPIC": [True, False]}
  31. default_options = {"shared": False, "fPIC": True}
  32. generators = "cmake"
  33. `
  34. )
  35. func TestParseConanfile(t *testing.T) {
  36. metadata, err := ParseConanfile(strings.NewReader(contentConanfile))
  37. assert.NoError(t, err)
  38. assert.Equal(t, license, metadata.License)
  39. assert.Equal(t, author, metadata.Author)
  40. assert.Equal(t, homepage, metadata.ProjectURL)
  41. assert.Equal(t, url, metadata.RepositoryURL)
  42. assert.Equal(t, description, metadata.Description)
  43. assert.Equal(t, []string{topic1, topic2}, metadata.Keywords)
  44. }