1
0
mirror of https://github.com/gogs/gogs.git synced 2025-05-10 01:20:16 +00:00
ᴜɴᴋɴᴡᴏɴ 41f56ad05d
login_source: migrate to GORM and add tests ()
* Use GORM in all write paths

* Migrate to GORM

* Fix lint errors

* Use GORM  to init table

* dbutil: make writer detect error

* Add more tests

* Rename to clearTables

* db: finish adding tests

* osutil: add tests

* Fix load source files path
2020-04-11 20:18:05 +08:00

86 lines
1.4 KiB
Go

// Copyright 2020 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package osutil
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestIsFile(t *testing.T) {
tests := []struct {
path string
expVal bool
}{
{
path: "osutil.go",
expVal: true,
}, {
path: "../osutil",
expVal: false,
}, {
path: "not_found",
expVal: false,
},
}
for _, test := range tests {
t.Run("", func(t *testing.T) {
assert.Equal(t, test.expVal, IsFile(test.path))
})
}
}
func TestIsDir(t *testing.T) {
tests := []struct {
path string
expVal bool
}{
{
path: "osutil.go",
expVal: false,
}, {
path: "../osutil",
expVal: true,
}, {
path: "not_found",
expVal: false,
},
}
for _, test := range tests {
t.Run("", func(t *testing.T) {
assert.Equal(t, test.expVal, IsDir(test.path))
})
}
}
func TestIsExist(t *testing.T) {
tests := []struct {
path string
expVal bool
}{
{
path: "osutil.go",
expVal: true,
}, {
path: "../osutil",
expVal: true,
}, {
path: "not_found",
expVal: false,
},
}
for _, test := range tests {
t.Run("", func(t *testing.T) {
assert.Equal(t, test.expVal, IsExist(test.path))
})
}
}
func TestCurrentUsername(t *testing.T) {
// Make sure it does not blow up
CurrentUsername()
}