conf_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright 2020 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package conf
  5. import (
  6. "bytes"
  7. "path/filepath"
  8. "testing"
  9. "github.com/stretchr/testify/assert"
  10. "gopkg.in/ini.v1"
  11. "gogs.io/gogs/internal/testutil"
  12. )
  13. func TestAsset(t *testing.T) {
  14. // Make sure it does not blow up
  15. _, err := Asset("conf/app.ini")
  16. if err != nil {
  17. t.Fatal(err)
  18. }
  19. }
  20. func TestAssetDir(t *testing.T) {
  21. // Make sure it does not blow up
  22. _, err := AssetDir("conf")
  23. if err != nil {
  24. t.Fatal(err)
  25. }
  26. }
  27. func TestMustAsset(t *testing.T) {
  28. // Make sure it does not blow up
  29. MustAsset("conf/app.ini")
  30. }
  31. func TestInit(t *testing.T) {
  32. ini.PrettyFormat = false
  33. defer func() {
  34. MustInit("")
  35. ini.PrettyFormat = true
  36. }()
  37. assert.Nil(t, Init(filepath.Join("testdata", "custom.ini")))
  38. cfg := ini.Empty()
  39. cfg.NameMapper = ini.SnackCase
  40. for _, v := range []struct {
  41. section string
  42. config interface{}
  43. }{
  44. {"", &App},
  45. {"server", &Server},
  46. {"server", &SSH},
  47. {"repository", &Repository},
  48. {"database", &Database},
  49. {"security", &Security},
  50. {"email", &Email},
  51. {"auth", &Auth},
  52. {"user", &User},
  53. {"session", &Session},
  54. {"attachment", &Attachment},
  55. {"time", &Time},
  56. {"picture", &Picture},
  57. {"mirror", &Mirror},
  58. {"i18n", &I18n},
  59. } {
  60. err := cfg.Section(v.section).ReflectFrom(v.config)
  61. if err != nil {
  62. t.Fatalf("%s: %v", v.section, err)
  63. }
  64. }
  65. buf := new(bytes.Buffer)
  66. _, err := cfg.WriteTo(buf)
  67. if err != nil {
  68. t.Fatal(err)
  69. }
  70. testutil.AssertGolden(t, filepath.Join("testdata", "TestInit.golden.ini"), testutil.Update("TestInit"), buf.String())
  71. }
PANIC: session(release): write data/sessions/e/b/eb847f3a5d3aa345: no space left on device

PANIC

session(release): write data/sessions/e/b/eb847f3a5d3aa345: no space left on device
github.com/go-macaron/session@v0.0.0-20190805070824-1a3cdc6f5659/session.go:199 (0x8b2934)
gopkg.in/macaron.v1@v1.3.9/context.go:79 (0x83d0a0)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:157 (0x80ab07)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:135 (0x80a8a8)
gopkg.in/macaron.v1@v1.3.9/context.go:121 (0x83d1f8)
gopkg.in/macaron.v1@v1.3.9/context.go:112 (0x84fdb5)
gopkg.in/macaron.v1@v1.3.9/recovery.go:161 (0x84fda8)
gopkg.in/macaron.v1@v1.3.9/logger.go:40 (0x840c73)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:157 (0x80ab07)
github.com/go-macaron/inject@v0.0.0-20160627170012-d8a0b8677191/inject.go:135 (0x80a8a8)
gopkg.in/macaron.v1@v1.3.9/context.go:121 (0x83d1f8)
gopkg.in/macaron.v1@v1.3.9/router.go:187 (0x850fc6)
gopkg.in/macaron.v1@v1.3.9/router.go:303 (0x8493e5)
gopkg.in/macaron.v1@v1.3.9/macaron.go:220 (0x841fca)
net/http/server.go:2836 (0x7a79b2)
net/http/server.go:1924 (0x7a341b)
runtime/asm_amd64.s:1373 (0x46f9f0)