Skip to content

Commit

Permalink
🧪 e2e tests restructured
Browse files Browse the repository at this point in the history
  • Loading branch information
yusufcanb committed Mar 13, 2024
1 parent 6ecaaab commit aa6465a
Show file tree
Hide file tree
Showing 8 changed files with 231 additions and 154 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ jobs:
- name: Install dependencies
run: pip install -r e2e/requirements.txt

- name: Run Robot Framework
run: robot --outputdir dist --name tlm --exclude requires=ollama tests/
- name: Run Tests wo/ Ollama
run: robot --outputdir dist --name tlm --exclude requires=ollama tlm.robot
working-directory: e2e/

- name: Archive e2e artifacts
Expand Down
67 changes: 0 additions & 67 deletions e2e/tests/config.robot

This file was deleted.

30 changes: 0 additions & 30 deletions e2e/tests/deploy.robot

This file was deleted.

29 changes: 0 additions & 29 deletions e2e/tests/explain.robot

This file was deleted.

26 changes: 0 additions & 26 deletions e2e/tests/suggest.robot

This file was deleted.

51 changes: 51 additions & 0 deletions e2e/tlm.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
*** Settings ***
Library OperatingSystem
Library tlm_lib.py


*** Variables ***
${help} tlm help
${version} tlm version
${config} tlm config
${suggest} tlm suggest 'list all files in cwd'
${explain} tlm explain 'ls -all'


*** Keywords ***
Run Command
[Arguments] ${command}
${rc} ${output}= Run and Return RC and Output ${command}
Log Return Code: ${rc}${\n}Output:${\n}${output}

RETURN ${rc} ${output}

Run Help
${rc} ${output}= Run Command ${help}
RETURN ${rc} ${output}

Run Version
${rc} ${output}= Run Command ${version}
RETURN ${rc} ${output}

Run Suggestion
${rc} ${output}= Run Command ${suggest}
RETURN ${rc} ${output}

Run Explain
${rc} ${output}= Run Command ${explain}
RETURN ${rc} ${output}

Set Config
[Arguments] ${key} ${value}
Log ${config} set ${key} ${value}
${rc} ${output}= Run Command ${config} set ${key} ${value}
RETURN ${rc} ${output}

Get Config
[Arguments] ${key}
Log ${config} get ${key}
${rc} ${output}= Run Command ${config} get ${key}
RETURN ${rc} ${output}

Remove Config File
Remove File ~/.tlm.yaml
157 changes: 157 additions & 0 deletions e2e/tlm.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
*** Settings ***
Library Collections
Resource tlm.resource
Suite Setup Log Variables

*** Variables ***
${OLLAMA_ENABLED} ${TRUE}


*** Test Cases ***
help
tlm help

version
tlm version

config
[Setup] Remove Config File

# Shell
tlm config set shell invalid (negative)
@{shells}= Create List bash powershell auto zsh
FOR ${value} IN @{shells}
tlm config set shell ${value} (positive)
tlm config get shell (positive) ${value} # Check if the value is set
END

# Ollama Host
tlm config set llm.host invalid-ollama-url (negative)
tlm config set llm.host http://ollama:8080 (positive)

@{prefs}= Create List stable balanced creative
# Explain Preference
tlm config set llm.explain invalid-pref (negative)
FOR ${value} IN @{prefs}
tlm config set llm.explain ${value} (positive)
tlm config get llm.explain (positive) ${value} # Check if the value is set
END

# Suggest Preference
tlm config set llm.suggest invalid-pref (negative)
FOR ${value} IN @{prefs}
tlm config set llm.suggest ${value} (positive)
tlm config get llm.suggest (positive) ${value} # Check if the value is set
END
[Teardown] Remove Config File

deploy (p)
[Tags] deploy requires=ollama
tlm deploy (positive)

deploy (n)
[Tags] deploy
tlm deploy (negative)

suggest (p)
[Tags] suggest requires=ollama
tlm suggest 'list all hidden files in cwd' (positive)

suggest (n)
[Tags] suggest
tlm suggest 'list all hidden files in cwd' (negative)

explain (p)
[Tags] explain requires=ollama
tlm explain 'ls -all' (positive)

explain (n)
[Tags] explain
tlm explain 'ls -all' (negative)


*** Keywords ***
# ------ Config ------

tlm config set ${key} ${value} (positive)
${rc} ${output}= Set Config ${key} ${value}

Should Be Equal As Integers ${rc} 0
Should Contain ${output} ${key} = ${value}
Should Contain ${output} (ok)
Should Not Contain ${output} (err)

tlm config set ${key} ${value} (negative)
${rc} ${output}= Set Config ${key} ${value}
Should Not Be Equal As Integers ${rc} 0

tlm config get ${key} (positive)
[Arguments] ${value}
${rc} ${output}= Get Config ${key}

Should Be Equal As Integers ${rc} 0
Should Contain ${output} ${key} = ${value}

# ------ Version & Help ------

tlm help
${rc} ${output}= Run Help
Should Be Equal As Integers ${rc} 0
Should Contain ${output} NAME:
Should Contain ${output} USAGE:
Should Contain ${output} VERSION:
Should Contain ${output} COMMANDS:

tlm version
${rc} ${output}= Run Version
Should Be Equal As Integers ${rc} 0
Version Should Be Correct ${output}

# ------ Deploy --------

tlm deploy (positive)
[Tags] requires=ollama
${rc} ${output}= Run Command tlm deploy

Should Be Equal As Integers ${rc} 0

tlm deploy (negative)
${rc} ${output}= Run Command tlm deploy

Should Be Equal As Integers ${rc} 255
Should Contain ${output} (err)
Should Contain
... ${output}
... Ollama connection failed. Please check your Ollama if it's running or configured correctly.

# ------ Suggest --------

tlm suggest '${prompt}' (positive)
${rc} ${output}= Run Command tlm suggest '${prompt}'

Should Be Equal As Integers ${rc} 0

tlm suggest '${prompt}' (negative)
${rc} ${output}= Run Command tlm suggest '${prompt}'

Should Be Equal As Integers ${rc} 255
Should Contain ${output} (err)
Should Contain
... ${output}
... Ollama connection failed. Please check your Ollama if it's running or configured correctly.

# ------ Explain --------

tlm explain '${prompt}' (positive)
${rc} ${output}= Run Command tlm explain '${prompt}'

Should Be Equal As Integers ${rc} 0

tlm explain '${prompt}' (negative)
${rc} ${output}= Run Command tlm explain '${prompt}'

Should Be Equal As Integers ${rc} 255
Should Contain ${output} (err)
Should Contain
... ${output}
... Ollama connection failed. Please check your Ollama if it's running or configured correctly.
Loading

0 comments on commit aa6465a

Please sign in to comment.