2018-12-04 05:57:11 +00:00
|
|
|
// Statping
|
2018-08-16 06:22:20 +00:00
|
|
|
// Copyright (C) 2018. Hunter Long and the project contributors
|
|
|
|
// Written by Hunter Long <info@socialeck.com> and the project contributors
|
|
|
|
//
|
2018-12-04 04:17:29 +00:00
|
|
|
// https://github.com/hunterlong/statping
|
2018-08-16 06:22:20 +00:00
|
|
|
//
|
|
|
|
// The licenses for most software and other practical works are designed
|
|
|
|
// to take away your freedom to share and change the works. By contrast,
|
|
|
|
// the GNU General Public License is intended to guarantee your freedom to
|
|
|
|
// share and change all versions of a program--to make sure it remains free
|
|
|
|
// software for all its users.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2018-08-11 16:24:32 +00:00
|
|
|
package source
|
|
|
|
|
|
|
|
import (
|
2018-12-04 04:17:29 +00:00
|
|
|
"github.com/hunterlong/statping/utils"
|
2018-08-11 16:24:32 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
dir string
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
dir = utils.Directory
|
|
|
|
utils.InitLogs()
|
|
|
|
Assets()
|
2019-12-30 03:34:49 +00:00
|
|
|
utils.DeleteDirectory(dir + "/assets")
|
2018-08-11 16:24:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCore_UsingAssets(t *testing.T) {
|
2018-08-16 20:55:30 +00:00
|
|
|
assert.False(t, UsingAssets(dir))
|
2018-08-11 16:24:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCreateAssets(t *testing.T) {
|
|
|
|
assert.Nil(t, CreateAllAssets(dir))
|
2018-08-16 20:55:30 +00:00
|
|
|
assert.True(t, UsingAssets(dir))
|
2019-01-17 04:59:07 +00:00
|
|
|
assert.FileExists(t, dir+"/assets/css/base.css")
|
|
|
|
assert.FileExists(t, dir+"/assets/scss/base.scss")
|
2018-08-11 16:24:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCompileSASS(t *testing.T) {
|
2018-11-07 17:19:56 +00:00
|
|
|
CompileSASS(dir)
|
2018-08-16 20:55:30 +00:00
|
|
|
assert.True(t, UsingAssets(dir))
|
2018-08-11 16:24:32 +00:00
|
|
|
}
|
|
|
|
|
2018-08-16 02:22:10 +00:00
|
|
|
func TestSaveAsset(t *testing.T) {
|
|
|
|
data := []byte("BODY { color: black; }")
|
|
|
|
asset := SaveAsset(data, dir, "scss/theme.scss")
|
|
|
|
assert.Nil(t, asset)
|
|
|
|
assert.FileExists(t, dir+"/assets/scss/theme.scss")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestOpenAsset(t *testing.T) {
|
|
|
|
asset := OpenAsset(dir, "scss/theme.scss")
|
|
|
|
assert.NotEmpty(t, asset)
|
|
|
|
}
|
|
|
|
|
2018-08-11 16:24:32 +00:00
|
|
|
func TestDeleteAssets(t *testing.T) {
|
|
|
|
assert.Nil(t, DeleteAllAssets(dir))
|
2018-08-16 20:55:30 +00:00
|
|
|
assert.False(t, UsingAssets(dir))
|
2018-08-11 16:24:32 +00:00
|
|
|
}
|
2018-08-16 02:22:10 +00:00
|
|
|
|
|
|
|
func TestCopyToPluginFailed(t *testing.T) {
|
|
|
|
assert.Nil(t, DeleteAllAssets(dir))
|
2018-08-16 20:55:30 +00:00
|
|
|
assert.False(t, UsingAssets(dir))
|
2018-08-16 02:22:10 +00:00
|
|
|
}
|
2018-10-06 06:38:33 +00:00
|
|
|
|
|
|
|
func ExampleSaveAsset() {
|
|
|
|
data := []byte("alert('helloooo')")
|
|
|
|
SaveAsset(data, "js", "test.js")
|
|
|
|
}
|
|
|
|
|
|
|
|
func ExampleOpenAsset() {
|
|
|
|
OpenAsset("js", "main.js")
|
|
|
|
}
|