Skip to content

Commit

Permalink
make executable name arg
Browse files Browse the repository at this point in the history
  • Loading branch information
amishas157 committed Nov 26, 2024
1 parent 8a45838 commit 39e63e4
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 13 deletions.
8 changes: 6 additions & 2 deletions cmd/command_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/xitongsys/parquet-go/writer"
)

var executableName = "stellar-etl"
var update = flag.Bool("update", false, "update the Golden files of this test")
var gotFolder = "testdata/got/"

Expand Down Expand Up @@ -209,7 +208,10 @@ func indexOf(l []string, s string) int {
return -1
}

func RunCLITest(t *testing.T, test CliTest, GoldenFolder string) {
func RunCLITest(t *testing.T, test CliTest, GoldenFolder string, executableName string) {
if executableName == "" {
executableName = "stellar-etl"
}
flag.Parse()
t.Run(test.Name, func(t *testing.T) {
dir, err := os.Getwd()
Expand All @@ -236,7 +238,9 @@ func RunCLITest(t *testing.T, test CliTest, GoldenFolder string) {
}

cmd := exec.Command(path.Join(dir, executableName), test.Args...)
fmt.Printf("Command: %s %v\n", path.Join(dir, executableName), test.Args)
errOut, actualError := cmd.CombinedOutput()
fmt.Println(actualError)
if idxOfOutputArg > -1 {
stat, err = os.Stat(outLocation)
assert.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/export_assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ func TestExportAssets(t *testing.T) {
}

for _, test := range tests {
RunCLITest(t, test, "testdata/assets/")
RunCLITest(t, test, "testdata/assets/", "")
}
}
2 changes: 1 addition & 1 deletion cmd/export_contract_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ func TestExportContractEvents(t *testing.T) {
}

for _, test := range tests {
RunCLITest(t, test, "testdata/contract_events/")
RunCLITest(t, test, "testdata/contract_events/", "")
}
}
2 changes: 1 addition & 1 deletion cmd/export_effects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ func TestExportEffects(t *testing.T) {
}

for _, test := range tests {
RunCLITest(t, test, "testdata/effects/")
RunCLITest(t, test, "testdata/effects/", "")
}
}
2 changes: 1 addition & 1 deletion cmd/export_ledger_entry_changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ func TestExportChanges(t *testing.T) {
}

for _, test := range tests {
RunCLITest(t, test, "testdata/changes/")
RunCLITest(t, test, "testdata/changes/", "")
}
}
2 changes: 1 addition & 1 deletion cmd/export_ledger_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ func TestExportLedgerTransaction(t *testing.T) {
}

for _, test := range tests {
RunCLITest(t, test, "testdata/ledger_transactions/")
RunCLITest(t, test, "testdata/ledger_transactions/", "")
}
}
4 changes: 2 additions & 2 deletions cmd/export_ledgers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestMain(m *testing.M) {
}

// This does the setup for further tests. It generates an executeable that can be run on the command line by other tests
buildCmd := exec.Command("go", "build", "-o", executableName)
buildCmd := exec.Command("go", "build", "-o", "stellar-etl")
if err := buildCmd.Run(); err != nil {
cmdLogger.Error("could not build executable", err)
os.Exit(1)
Expand Down Expand Up @@ -73,6 +73,6 @@ func TestExportLedger(t *testing.T) {
}

for _, test := range tests {
RunCLITest(t, test, "testdata/ledgers/")
RunCLITest(t, test, "testdata/ledgers/", "")
}
}
2 changes: 1 addition & 1 deletion cmd/export_operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ func TestExportOperations(t *testing.T) {
}

for _, test := range tests {
RunCLITest(t, test, "testdata/operations/")
RunCLITest(t, test, "testdata/operations/", "")
}
}
2 changes: 1 addition & 1 deletion cmd/export_trades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ func TestExportTrades(t *testing.T) {
}

for _, test := range tests {
RunCLITest(t, test, "testdata/trades/")
RunCLITest(t, test, "testdata/trades/", "")
}
}
2 changes: 1 addition & 1 deletion cmd/export_transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ func TestExportTransactions(t *testing.T) {
}

for _, test := range tests {
RunCLITest(t, test, "testdata/transactions/")
RunCLITest(t, test, "testdata/transactions/", "")
}
}
2 changes: 1 addition & 1 deletion cmd/get_ledger_range_from_times_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ func TestConvertTimes(t *testing.T) {
}

for _, test := range tests {
RunCLITest(t, test, "testdata/ranges/")
RunCLITest(t, test, "testdata/ranges/", "")
}
}

0 comments on commit 39e63e4

Please sign in to comment.