*: use path/filepath
instead of path
This commit is contained in:
parent
b99e2b50e2
commit
836d37b275
@ -20,7 +20,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -218,7 +218,7 @@ func migrate(source string) error {
|
|||||||
log.Info("running database migrations")
|
log.Info("running database migrations")
|
||||||
|
|
||||||
_, filename, _, _ := runtime.Caller(1)
|
_, filename, _, _ := runtime.Caller(1)
|
||||||
migrationDir := path.Join(path.Dir(filename), "/migrations/")
|
migrationDir := filepath.Join(filepath.Dir(filename), "/migrations/")
|
||||||
conf := &goose.DBConf{
|
conf := &goose.DBConf{
|
||||||
MigrationsDir: migrationDir,
|
MigrationsDir: migrationDir,
|
||||||
Driver: goose.DBDriver{
|
Driver: goose.DBDriver{
|
||||||
|
@ -17,7 +17,7 @@ package pgsql
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ func generateTestConfig(testName string, loadFixture bool) config.RegistrableCom
|
|||||||
var fixturePath string
|
var fixturePath string
|
||||||
if loadFixture {
|
if loadFixture {
|
||||||
_, filename, _, _ := runtime.Caller(0)
|
_, filename, _, _ := runtime.Caller(0)
|
||||||
fixturePath = path.Join(path.Dir(filename)) + "/testdata/data.sql"
|
fixturePath = filepath.Join(filepath.Dir(filename)) + "/testdata/data.sql"
|
||||||
}
|
}
|
||||||
|
|
||||||
source := fmt.Sprintf("postgresql://postgres@127.0.0.1:5432/%s?sslmode=disable", dbName)
|
source := fmt.Sprintf("postgresql://postgres@127.0.0.1:5432/%s?sslmode=disable", dbName)
|
||||||
|
@ -16,7 +16,7 @@ package debian
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ func TestDebianParser(t *testing.T) {
|
|||||||
_, filename, _, _ := runtime.Caller(0)
|
_, filename, _, _ := runtime.Caller(0)
|
||||||
|
|
||||||
// Test parsing testdata/fetcher_debian_test.json
|
// Test parsing testdata/fetcher_debian_test.json
|
||||||
testFile, _ := os.Open(path.Join(path.Dir(filename)) + "/testdata/fetcher_debian_test.json")
|
testFile, _ := os.Open(filepath.Join(filepath.Dir(filename)) + "/testdata/fetcher_debian_test.json")
|
||||||
response, err := buildResponse(testFile, "")
|
response, err := buildResponse(testFile, "")
|
||||||
if assert.Nil(t, err) && assert.Len(t, response.Vulnerabilities, 3) {
|
if assert.Nil(t, err) && assert.Len(t, response.Vulnerabilities, 3) {
|
||||||
for _, vulnerability := range response.Vulnerabilities {
|
for _, vulnerability := range response.Vulnerabilities {
|
||||||
|
@ -16,7 +16,7 @@ package rhel
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ import (
|
|||||||
|
|
||||||
func TestRHELParser(t *testing.T) {
|
func TestRHELParser(t *testing.T) {
|
||||||
_, filename, _, _ := runtime.Caller(0)
|
_, filename, _, _ := runtime.Caller(0)
|
||||||
path := path.Join(path.Dir(filename))
|
path := filepath.Join(filepath.Dir(filename))
|
||||||
|
|
||||||
// Test parsing testdata/fetcher_rhel_test.1.xml
|
// Test parsing testdata/fetcher_rhel_test.1.xml
|
||||||
testFile, _ := os.Open(path + "/testdata/fetcher_rhel_test.1.xml")
|
testFile, _ := os.Open(path + "/testdata/fetcher_rhel_test.1.xml")
|
||||||
|
@ -16,7 +16,7 @@ package ubuntu
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ import (
|
|||||||
|
|
||||||
func TestUbuntuParser(t *testing.T) {
|
func TestUbuntuParser(t *testing.T) {
|
||||||
_, filename, _, _ := runtime.Caller(0)
|
_, filename, _, _ := runtime.Caller(0)
|
||||||
path := path.Join(path.Dir(filename))
|
path := filepath.Join(filepath.Dir(filename))
|
||||||
|
|
||||||
// Test parsing testdata/fetcher_
|
// Test parsing testdata/fetcher_
|
||||||
testData, _ := os.Open(path + "/testdata/fetcher_ubuntu_test.txt")
|
testData, _ := os.Open(path + "/testdata/fetcher_ubuntu_test.txt")
|
||||||
|
@ -17,7 +17,7 @@ package utils
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -65,10 +65,10 @@ func TestString(t *testing.T) {
|
|||||||
func TestTar(t *testing.T) {
|
func TestTar(t *testing.T) {
|
||||||
var err error
|
var err error
|
||||||
var data map[string][]byte
|
var data map[string][]byte
|
||||||
_, filepath, _, _ := runtime.Caller(0)
|
_, path, _, _ := runtime.Caller(0)
|
||||||
testDataDir := "/testdata"
|
testDataDir := "/testdata"
|
||||||
for _, filename := range []string{"utils_test.tar.gz", "utils_test.tar.bz2", "utils_test.tar.xz", "utils_test.tar"} {
|
for _, filename := range []string{"utils_test.tar.gz", "utils_test.tar.bz2", "utils_test.tar.xz", "utils_test.tar"} {
|
||||||
testArchivePath := path.Join(path.Dir(filepath), testDataDir, filename)
|
testArchivePath := filepath.Join(filepath.Dir(path), testDataDir, filename)
|
||||||
|
|
||||||
// Extract non compressed data
|
// Extract non compressed data
|
||||||
data, err = SelectivelyExtractArchive(bytes.NewReader([]byte("that string does not represent a tar or tar-gzip file")), "", []string{}, 0)
|
data, err = SelectivelyExtractArchive(bytes.NewReader([]byte("that string does not represent a tar or tar-gzip file")), "", []string{}, 0)
|
||||||
|
@ -16,7 +16,7 @@ package feature
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ type FeatureVersionTest struct {
|
|||||||
|
|
||||||
func LoadFileForTest(name string) []byte {
|
func LoadFileForTest(name string) []byte {
|
||||||
_, filename, _, _ := runtime.Caller(0)
|
_, filename, _, _ := runtime.Caller(0)
|
||||||
d, _ := ioutil.ReadFile(path.Join(path.Dir(filename)) + "/" + name)
|
d, _ := ioutil.ReadFile(filepath.Join(filepath.Dir(filename)) + "/" + name)
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
package worker
|
package worker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ func newMockDatastore() *mockDatastore {
|
|||||||
|
|
||||||
func TestProcessWithDistUpgrade(t *testing.T) {
|
func TestProcessWithDistUpgrade(t *testing.T) {
|
||||||
_, f, _, _ := runtime.Caller(0)
|
_, f, _, _ := runtime.Caller(0)
|
||||||
testDataPath := path.Join(path.Dir(f)) + "/testdata/DistUpgrade/"
|
testDataPath := filepath.Join(filepath.Dir(f)) + "/testdata/DistUpgrade/"
|
||||||
|
|
||||||
// Create a mock datastore.
|
// Create a mock datastore.
|
||||||
datastore := newMockDatastore()
|
datastore := newMockDatastore()
|
||||||
|
Loading…
Reference in New Issue
Block a user