✨ Add plain text formatter
This commit is contained in:
parent
286ac4557d
commit
89e6c2b3bd
5 changed files with 276 additions and 0 deletions
35
formatters/new_test.go
Normal file
35
formatters/new_test.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package formatters
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"codeberg.org/danjones000/my-log/config"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestKinds(t *testing.T) {
|
||||
assert.Equal(t, []string{"plain"}, Kinds())
|
||||
}
|
||||
|
||||
func TestNewUnsupported(t *testing.T) {
|
||||
f, err := New("nope")
|
||||
assert.Nil(t, f)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestNewCantGetConfig(t *testing.T) {
|
||||
f, _ := os.CreateTemp("", "test")
|
||||
oldConf := config.ConfigPath
|
||||
config.ConfigPath = f.Name()
|
||||
defer f.Close()
|
||||
defer func() {
|
||||
config.ConfigPath = oldConf
|
||||
}()
|
||||
|
||||
fmt.Fprint(f, `{"not":"toml"}`)
|
||||
form, err := New("plain")
|
||||
assert.Nil(t, form)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue