Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
MatiasG19 committed Sep 21, 2023
1 parent 7dddb0b commit 495bbc2
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CI

on:
push:
branches:
- '**'
release:
types: [released, prereleased]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Add permissions
run: chmod +x test.sh && chmod +x AppToGrid.sh

- name: Test
run: test.sh
67 changes: 67 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

##################################
# arrange
##################################
echo "#!/bin/bash
echo Hello world!
" > TestApp.sh

##################################
# act
##################################
printf '%s\n' TestApp ./TestApp.sh y | ./AppToGrid.sh

##################################
# assert
##################################
## Check if executable exists
if [ ! -f /usr/bin/TestApp.sh ]; then
echo "Assert 1" >> test.log
echo "Executable does not exist in /usr/bin/" >> test.log
echo
fi

## Check if desktop file exists
if [ ! -f /usr/share/applications/TestApp.desktop ]; then
echo "Assert 2" >> test.log
echo ".desktop file does not exist in /usr/share/applications/" >> test.log
echo
fi

## .desktop file content
DESKTOP="[Desktop Entry]
Type=Application
Terminal=false
Exec='$pathToExe'
Name=$appName
Comment=$appName
Keywords=$appName;"
diff <(echo $DESKTOP) <(echo /usr/share/applications/TestApp.sh)
if echo $? == 1
then
echo "Assert 3" >> test.log
echo ".desktop file content is different" >> test.log
echo diff <(echo textio) <(echo text) >> test.log
echo
fi

## Check executable permissions
if [ ! $(ls -l /usr/bin/TestApp.sh | cut -c 10-10) == "x" ]
then
echo "Assert 4" >> test.log
echo "Executable has no execution permissions" >> test.log
echo
fi

## Fail test when logfile exists
if [ -f test.log ]; then
cat test.log
exit 1
fi


if [ ! $(ls -l ./test/text.txt | cut -c 10-10) == "x" ]
then
echo hello
fi

0 comments on commit 495bbc2

Please sign in to comment.