36 lines
		
	
	
	
		
			633 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			36 lines
		
	
	
	
		
			633 B
		
	
	
	
		
			Go
		
	
	
	
	
	
|  | 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) | ||
|  | } |