mirror of https://github.com/jlelse/GoBlog
Simple blogging system written in Go
https://goblog.app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
619 B
30 lines
619 B
package main |
|
|
|
import ( |
|
"os" |
|
"path/filepath" |
|
"strings" |
|
"testing" |
|
|
|
"github.com/stretchr/testify/assert" |
|
"github.com/stretchr/testify/require" |
|
) |
|
|
|
func Test_localMediaStorage(t *testing.T) { |
|
testDir := t.TempDir() |
|
|
|
l := &localMediaStorage{ |
|
mediaURL: "https://example.com", |
|
path: testDir, |
|
} |
|
|
|
testFileContent := "This is a test" |
|
|
|
loc, err := l.save("test.txt", strings.NewReader(testFileContent)) |
|
require.Nil(t, err) |
|
assert.Equal(t, "https://example.com/test.txt", loc) |
|
|
|
file, err := os.ReadFile(filepath.Join(testDir, "test.txt")) |
|
require.Nil(t, err) |
|
assert.Equal(t, testFileContent, string(file)) |
|
}
|
|
|