Skip to content

Commit 5e608cc

Browse files
jshaDaniel McCarney
authored andcommitted
tests: use relative paths in Go integration tests. (letsencrypt#4526)
This makes it simpler to specify paths to testdata and config files. Fixes letsencrypt#4508
1 parent e402156 commit 5e608cc

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

test/config-next/orphan-finder.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
},
77

88
"tls": {
9-
"caCertFile": "../../test/grpc-creds/minica.pem",
10-
"certFile": "../../test/grpc-creds/orphan-finder.boulder/cert.pem",
11-
"keyFile": "../../test/grpc-creds/orphan-finder.boulder/key.pem"
9+
"caCertFile": "test/grpc-creds/minica.pem",
10+
"certFile": "test/grpc-creds/orphan-finder.boulder/cert.pem",
11+
"keyFile": "test/grpc-creds/orphan-finder.boulder/key.pem"
1212
},
1313

1414
"ocspGeneratorService": {

test/config/orphan-finder.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
},
77

88
"tls": {
9-
"caCertFile": "../../test/grpc-creds/minica.pem",
10-
"certFile": "../../test/grpc-creds/orphan-finder.boulder/cert.pem",
11-
"keyFile": "../../test/grpc-creds/orphan-finder.boulder/key.pem"
9+
"caCertFile": "test/grpc-creds/minica.pem",
10+
"certFile": "test/grpc-creds/orphan-finder.boulder/cert.pem",
11+
"keyFile": "test/grpc-creds/orphan-finder.boulder/key.pem"
1212
},
1313

1414
"ocspGeneratorService": {

test/integration/common_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ import (
1818
"github.com/eggsampler/acme/v2"
1919
)
2020

21+
func init() {
22+
// Go tests get run in the directory their source code lives in. For these
23+
// test cases, that would be "test/integration." However, it's easier to
24+
// reference test data and config files for integration tests relative to the
25+
// root of the Boulder repo, so we run all of these tests from there instead.
26+
os.Chdir("../../")
27+
}
28+
2129
var (
2230
OIDExtensionCTPoison = asn1.ObjectIdentifier{1, 3, 6, 1, 4, 1, 11129, 2, 4, 3}
2331
)

test/integration/orphan_finder_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ func TestOrphanFinder(t *testing.T) {
3939
io.WriteString(f, fmt.Sprintf(template, precert.SerialNumber.Bytes(),
4040
precert.Raw, cert.SerialNumber.Bytes(), cert.Raw))
4141
f.Close()
42-
cmd := exec.Command("../../bin/orphan-finder", "parse-ca-log",
43-
"--config", "../../"+os.Getenv("BOULDER_CONFIG_DIR")+"/orphan-finder.json",
42+
cmd := exec.Command("./bin/orphan-finder", "parse-ca-log",
43+
"--config", "./"+os.Getenv("BOULDER_CONFIG_DIR")+"/orphan-finder.json",
4444
"--log-file", f.Name())
4545
out, err := cmd.Output()
4646
if err != nil {
@@ -70,7 +70,7 @@ func makeFakeCert(precert bool) (*x509.Certificate, error) {
7070
if err != nil {
7171
return nil, err
7272
}
73-
issuerKeyBytes, err := ioutil.ReadFile("../test-ca.key")
73+
issuerKeyBytes, err := ioutil.ReadFile("test/test-ca.key")
7474
if err != nil {
7575
return nil, err
7676
}

0 commit comments

Comments
 (0)