-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add end-to-end tests * use ipfs/go-test * Set up signal handler sooner to that sigint right after start does not crash daemon * Update CHANGELOG Add basic end-to-end tests to rainbow. This is not a complete set of tests but is a place to start adding end-to-end tests. Fixes #89
- Loading branch information
Showing
5 changed files
with
84 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package main_test | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"path/filepath" | ||
"runtime" | ||
"testing" | ||
"time" | ||
|
||
testcmd "github.com/ipfs/go-test/cmd" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
const ( | ||
startTimeout = 5 * time.Second | ||
testTimeout = 15 * time.Second | ||
) | ||
|
||
func TestEndToEndTrustlessGatewayDomains(t *testing.T) { | ||
switch runtime.GOOS { | ||
case "windows": | ||
t.Skip("skipping test on", runtime.GOOS) | ||
} | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), testTimeout) | ||
defer cancel() | ||
|
||
runner := testcmd.NewRunner(t, t.TempDir()) | ||
|
||
// install rainbow | ||
runner.Run(ctx, "go", "install", ".") | ||
rainbow := filepath.Join(runner.Dir, "rainbow") | ||
|
||
args := testcmd.Args(rainbow, "--trustless-gateway-domains", "example.org") | ||
ready := testcmd.NewStdoutWatcher("IPFS Gateway listening") | ||
domain := testcmd.NewStdoutWatcher("RAINBOW_TRUSTLESS_GATEWAY_DOMAINS = example.org") | ||
cmdRainbow := runner.Start(ctx, args, ready, domain) | ||
|
||
startCtx, startCancel := context.WithTimeout(context.Background(), startTimeout) | ||
defer startCancel() | ||
|
||
err := ready.Wait(startCtx) | ||
require.NoError(t, err) | ||
t.Log("Rainbow is running") | ||
|
||
err = domain.Wait(startCtx) | ||
require.NoError(t, err) | ||
t.Log("Correct value set by cli flag --trustless-gateway-domains") | ||
|
||
runner.Stop(cmdRainbow, 5*time.Second) | ||
t.Log("Rainbow stopped") | ||
|
||
runner.Env = append(runner.Env, fmt.Sprintf("%s=%s", "RAINBOW_TRUSTLESS_GATEWAY_DOMAINS", "example.com")) | ||
domain = testcmd.NewStdoutWatcher("RAINBOW_TRUSTLESS_GATEWAY_DOMAINS = example.com") | ||
cmdRainbow = runner.Start(ctx, testcmd.Args(rainbow), ready, domain) | ||
|
||
startCancel() | ||
startCtx, startCancel = context.WithTimeout(context.Background(), startTimeout) | ||
defer startCancel() | ||
|
||
err = ready.Wait(startCtx) | ||
require.NoError(t, err) | ||
t.Log("Rainbow is running") | ||
|
||
err = domain.Wait(startCtx) | ||
require.NoError(t, err) | ||
t.Log("Correct value set by environ var RAINBOW_TRUSTLESS_GATEWAY_DOMAINS") | ||
|
||
runner.Stop(cmdRainbow, 5*time.Second) | ||
t.Log("Rainbow stopped") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters