*: use path/filepath instead of path

This commit is contained in:
Quentin Machu 2016-05-17 17:30:40 -04:00
parent b99e2b50e2
commit 836d37b275
8 changed files with 17 additions and 17 deletions

View File

@ -20,7 +20,7 @@ import (
"fmt"
"io/ioutil"
"net/url"
"path"
"path/filepath"
"runtime"
"strings"
"time"
@ -218,7 +218,7 @@ func migrate(source string) error {
log.Info("running database migrations")
_, filename, _, _ := runtime.Caller(1)
migrationDir := path.Join(path.Dir(filename), "/migrations/")
migrationDir := filepath.Join(filepath.Dir(filename), "/migrations/")
conf := &goose.DBConf{
MigrationsDir: migrationDir,
Driver: goose.DBDriver{

View File

@ -17,7 +17,7 @@ package pgsql
import (
"fmt"
"os"
"path"
"path/filepath"
"runtime"
"strings"
@ -40,7 +40,7 @@ func generateTestConfig(testName string, loadFixture bool) config.RegistrableCom
var fixturePath string
if loadFixture {
_, 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)

View File

@ -16,7 +16,7 @@ package debian
import (
"os"
"path"
"path/filepath"
"runtime"
"testing"
@ -29,7 +29,7 @@ func TestDebianParser(t *testing.T) {
_, filename, _, _ := runtime.Caller(0)
// 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, "")
if assert.Nil(t, err) && assert.Len(t, response.Vulnerabilities, 3) {
for _, vulnerability := range response.Vulnerabilities {

View File

@ -16,7 +16,7 @@ package rhel
import (
"os"
"path"
"path/filepath"
"runtime"
"testing"
@ -27,7 +27,7 @@ import (
func TestRHELParser(t *testing.T) {
_, filename, _, _ := runtime.Caller(0)
path := path.Join(path.Dir(filename))
path := filepath.Join(filepath.Dir(filename))
// Test parsing testdata/fetcher_rhel_test.1.xml
testFile, _ := os.Open(path + "/testdata/fetcher_rhel_test.1.xml")

View File

@ -16,7 +16,7 @@ package ubuntu
import (
"os"
"path"
"path/filepath"
"runtime"
"testing"
@ -27,7 +27,7 @@ import (
func TestUbuntuParser(t *testing.T) {
_, filename, _, _ := runtime.Caller(0)
path := path.Join(path.Dir(filename))
path := filepath.Join(filepath.Dir(filename))
// Test parsing testdata/fetcher_
testData, _ := os.Open(path + "/testdata/fetcher_ubuntu_test.txt")

View File

@ -17,7 +17,7 @@ package utils
import (
"bytes"
"os"
"path"
"path/filepath"
"runtime"
"testing"
@ -65,10 +65,10 @@ func TestString(t *testing.T) {
func TestTar(t *testing.T) {
var err error
var data map[string][]byte
_, filepath, _, _ := runtime.Caller(0)
_, path, _, _ := runtime.Caller(0)
testDataDir := "/testdata"
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
data, err = SelectivelyExtractArchive(bytes.NewReader([]byte("that string does not represent a tar or tar-gzip file")), "", []string{}, 0)

View File

@ -16,7 +16,7 @@ package feature
import (
"io/ioutil"
"path"
"path/filepath"
"runtime"
"testing"
@ -32,7 +32,7 @@ type FeatureVersionTest struct {
func LoadFileForTest(name string) []byte {
_, filename, _, _ := runtime.Caller(0)
d, _ := ioutil.ReadFile(path.Join(path.Dir(filename)) + "/" + name)
d, _ := ioutil.ReadFile(filepath.Join(filepath.Dir(filename)) + "/" + name)
return d
}

View File

@ -15,7 +15,7 @@
package worker
import (
"path"
"path/filepath"
"runtime"
"testing"
@ -45,7 +45,7 @@ func newMockDatastore() *mockDatastore {
func TestProcessWithDistUpgrade(t *testing.T) {
_, f, _, _ := runtime.Caller(0)
testDataPath := path.Join(path.Dir(f)) + "/testdata/DistUpgrade/"
testDataPath := filepath.Join(filepath.Dir(f)) + "/testdata/DistUpgrade/"
// Create a mock datastore.
datastore := newMockDatastore()