|
14 | 14 | package hugo |
15 | 15 |
|
16 | 16 | import ( |
| 17 | + "bytes" |
17 | 18 | "context" |
18 | 19 | "testing" |
19 | 20 |
|
20 | 21 | "github.com/bep/logg" |
21 | 22 | qt "github.com/frankban/quicktest" |
| 23 | + "github.com/gohugoio/hugo/common/loggers" |
22 | 24 | ) |
23 | 25 |
|
24 | 26 | func TestDeprecationLogLevelFromVersion(t *testing.T) { |
@@ -59,3 +61,38 @@ func TestGetBuildInfo(t *testing.T) { |
59 | 61 | c.Assert(bi.GoVersion, qt.Not(qt.Equals), "") |
60 | 62 | } |
61 | 63 | } |
| 64 | + |
| 65 | +func TestWarnDeprecatedEdition(t *testing.T) { |
| 66 | + c := qt.New(t) |
| 67 | + |
| 68 | + origExtended, origWithdeploy := IsExtended, IsWithdeploy |
| 69 | + t.Cleanup(func() { |
| 70 | + IsExtended = origExtended |
| 71 | + IsWithdeploy = origWithdeploy |
| 72 | + loggers.SetGlobalLogger(nil) |
| 73 | + }) |
| 74 | + |
| 75 | + var buf bytes.Buffer |
| 76 | + loggers.SetGlobalLogger(loggers.New(loggers.Options{Level: logg.LevelInfo, StdErr: &buf})) |
| 77 | + |
| 78 | + IsExtended = true |
| 79 | + IsWithdeploy = false |
| 80 | + WarnDeprecatedEdition() |
| 81 | + c.Assert(buf.String(), qt.Contains, "the extended edition of the Hugo executable") |
| 82 | + c.Assert(buf.String(), qt.Contains, "Use the standard edition instead") |
| 83 | + |
| 84 | + buf.Reset() |
| 85 | + |
| 86 | + IsExtended = true |
| 87 | + IsWithdeploy = true |
| 88 | + WarnDeprecatedEdition() |
| 89 | + c.Assert(buf.String(), qt.Contains, "the extended_withdeploy edition of the Hugo executable") |
| 90 | + c.Assert(buf.String(), qt.Contains, "Use the withdeploy edition instead") |
| 91 | + |
| 92 | + buf.Reset() |
| 93 | + |
| 94 | + IsExtended = false |
| 95 | + IsWithdeploy = false |
| 96 | + WarnDeprecatedEdition() |
| 97 | + c.Assert(buf.String(), qt.Equals, "") |
| 98 | +} |
0 commit comments