Skip to content

Commit

Permalink
*: use path/filepath instead of path
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin-M committed May 20, 2016
1 parent b99e2b5 commit 836d37b
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions database/pgsql/pgsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"fmt"
"io/ioutil"
"net/url"
"path"
"path/filepath"
"runtime"
"strings"
"time"
Expand Down Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions database/pgsql/pgsql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package pgsql
import (
"fmt"
"os"
"path"
"path/filepath"
"runtime"
"strings"

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions updater/fetchers/debian/debian_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package debian

import (
"os"
"path"
"path/filepath"
"runtime"
"testing"

Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions updater/fetchers/rhel/rhel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package rhel

import (
"os"
"path"
"path/filepath"
"runtime"
"testing"

Expand All @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions updater/fetchers/ubuntu/ubuntu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package ubuntu

import (
"os"
"path"
"path/filepath"
"runtime"
"testing"

Expand All @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package utils
import (
"bytes"
"os"
"path"
"path/filepath"
"runtime"
"testing"

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions worker/detectors/feature/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package feature

import (
"io/ioutil"
"path"
"path/filepath"
"runtime"
"testing"

Expand All @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions worker/worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package worker

import (
"path"
"path/filepath"
"runtime"
"testing"

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 836d37b

Please sign in to comment.