test: resolved test issues

This commit is contained in:
Sheen Capadngan
2024-06-11 03:37:51 +08:00
parent 69b76aea64
commit cf9169ad6f
2 changed files with 13 additions and 17 deletions

View File

@@ -9,14 +9,15 @@ if [ ! -f "$TEST_ENV_FILE" ]; then
fi fi
# Export the variables # Export the variables
while IFS='=' read -r key value while IFS= read -r line
do do
# Skip empty lines and lines starting with # # Skip empty lines and lines starting with #
if [[ -z "$key" || "$key" =~ ^\# ]]; then if [[ -z "$line" || "$line" =~ ^\# ]]; then
continue continue
fi fi
# Use eval to correctly handle values with spaces # Read the key-value pair
eval export $key='$value' IFS='=' read -r key value <<< "$line"
eval export $key=\$value
done < "$TEST_ENV_FILE" done < "$TEST_ENV_FILE"
echo "Test environment variables set." echo "Test environment variables set."

View File

@@ -77,22 +77,19 @@ func UserLoginCmd() {
n, err := ptmx.Read(buf) n, err := ptmx.Read(buf)
if n > 0 { if n > 0 {
terminalOut := string(buf) terminalOut := string(buf)
if strings.Contains(terminalOut, "Add a new account") && step < 0 { if strings.Contains(terminalOut, "Infisical Cloud") && step < 0 {
step += 1
stepChan <- step
} else if strings.Contains(terminalOut, "Infisical Cloud") && step < 1 {
step += 1; step += 1;
stepChan <- step stepChan <- step
} else if strings.Contains(terminalOut, "Email") && step < 2 { } else if strings.Contains(terminalOut, "Email") && step < 1 {
step += 1; step += 1;
stepChan <- step stepChan <- step
} else if strings.Contains(terminalOut, "Password") && step < 3 { } else if strings.Contains(terminalOut, "Password") && step < 2 {
step += 1; step += 1;
stepChan <- step stepChan <- step
} else if strings.Contains(terminalOut, "Infisical organization") && step < 4 { } else if strings.Contains(terminalOut, "Infisical organization") && step < 3 {
step += 1; step += 1;
stepChan <- step stepChan <- step
} else if strings.Contains(terminalOut, "Enter passphrase") && step < 5 { } else if strings.Contains(terminalOut, "Enter passphrase") && step < 4 {
step += 1; step += 1;
stepChan <- step stepChan <- step
} }
@@ -106,17 +103,15 @@ func UserLoginCmd() {
for i := range stepChan { for i := range stepChan {
switch i { switch i {
case 0: case 0:
ptmx.Write([]byte("\n")) ptmx.Write([]byte("\n"))
case 1: case 1:
ptmx.Write([]byte("\n"))
case 2:
ptmx.Write([]byte(creds.UserEmail)) ptmx.Write([]byte(creds.UserEmail))
ptmx.Write([]byte("\n")) ptmx.Write([]byte("\n"))
case 3: case 2:
ptmx.Write([]byte(creds.UserPassword)) ptmx.Write([]byte(creds.UserPassword))
ptmx.Write([]byte("\n")) ptmx.Write([]byte("\n"))
case 4: case 3:
ptmx.Write([]byte("\n")) ptmx.Write([]byte("\n"))
} }
} }