| 1 |
package e2e_test |
| 2 |
|
| 3 |
import ( |
| 4 |
"bufio" |
| 5 |
"os" |
| 6 |
"strings" |
| 7 |
"testing" |
| 8 |
|
| 9 |
"github.com/onsi/ginkgo/v2" |
| 10 |
"github.com/onsi/gomega" |
| 11 |
) |
| 12 |
|
| 13 |
//nolint:paralleltest // Avoid using parallel test when making external calls |
| 14 |
func Test_Twilio_E2E(t *testing.T) { |
| 15 |
// Load .env file if it exists |
| 16 |
loadEnvFile(".env") |
| 17 |
|
| 18 |
gomega.RegisterFailHandler(ginkgo.Fail) |
| 19 |
ginkgo.RunSpecs(t, "Twilio E2E Tests") |
| 20 |
} |
| 21 |
|
| 22 |
// loadEnvFile loads environment variables from a .env file. |
| 23 |
func loadEnvFile(filename string) { |
| 24 |
file, err := os.Open(filename) |
| 25 |
if err != nil { |
| 26 |
// .env file doesn't exist, skip loading |
| 27 |
return |
| 28 |
} |
| 29 |
|
| 30 |
defer func() { _ = file.Close() }() |
| 31 |
|
| 32 |
scanner := bufio.NewScanner(file) |
| 33 |
for scanner.Scan() { |
| 34 |
line := strings.TrimSpace(scanner.Text()) |
| 35 |
if line == "" || strings.HasPrefix(line, "#") { |
| 36 |
continue |
| 37 |
} |
| 38 |
|
| 39 |
parts := strings.SplitN(line, "=", 2) |
| 40 |
if len(parts) == 2 { |
| 41 |
key := strings.TrimSpace(parts[0]) |
| 42 |
value := strings.TrimSpace(parts[1]) |
| 43 |
// Remove quotes if present |
| 44 |
value = strings.Trim(value, `"'`) |
| 45 |
_ = os.Setenv(key, value) // Ignore error as it's test setup |
| 46 |
} |
| 47 |
} |
| 48 |
} |