-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add .gitignore * rename github action file * add tests
- Loading branch information
Showing
6 changed files
with
154 additions
and
15 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode | ||
|
||
### VisualStudioCode ### | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
*.code-workspace | ||
|
||
### VisualStudioCode Patch ### | ||
# Ignore all local history of files | ||
.history | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: "3.8" | ||
|
||
services: | ||
sut: | ||
build: | ||
context: . | ||
target: test-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
docker-compose --file docker-compose.test.yml up --build | ||
docker-compose --file docker-compose.test.yml down --volumes --remove-orphans --rmi all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import os | ||
import platform | ||
import pytest | ||
import testinfra | ||
|
||
HOME_PATH = os.environ['HOME'] | ||
ROOT = 'root' | ||
USER_NAME = 'zsh-user' | ||
USER_GROUP = 'www-data' | ||
FONTS_PATH = '/usr/local/share/fonts' | ||
OH_MY_ZSH_PATH = HOME_PATH + '/.oh-my-zsh' | ||
|
||
|
||
def test_python(): | ||
assert platform.python_version() == '3.8.5' | ||
|
||
|
||
def test_pip_packages(host): | ||
pip_packages = host.pip_package.get_packages | ||
|
||
assert pip_packages()['pip']['version'] == '20.1.1' | ||
assert pip_packages()['pytest']['version'] == '5.4.3' | ||
assert pip_packages()['testinfra']['version'] == '5.2.2' | ||
|
||
|
||
@pytest.mark.parametrize('name,version', [ | ||
('git', ''), | ||
('wget', ''), | ||
('zsh', ''), | ||
('lsd', '0.17.0'), | ||
]) | ||
def test_packages(host, name, version): | ||
package = host.package(name) | ||
|
||
assert package.is_installed | ||
if version: | ||
assert package.version.startswith(version) | ||
|
||
|
||
def test_current_user(host): | ||
user = host.user() | ||
|
||
assert user.name == USER_NAME | ||
assert user.group == USER_GROUP | ||
|
||
|
||
def test_home_directory(host): | ||
assert HOME_PATH == '/home/' + USER_NAME | ||
|
||
|
||
def test_fzf_package(host): | ||
# workaround to test if fzf is installed (not detected as installed by testinfra) | ||
fzf_version_cmd = host.run('fzf --version') | ||
|
||
assert fzf_version_cmd.succeeded | ||
assert fzf_version_cmd.stdout.startswith('0.21.1') | ||
|
||
|
||
@pytest.mark.parametrize('path,user,group', [ | ||
(OH_MY_ZSH_PATH + '/custom/plugins/zsh-syntax-highlighting', USER_NAME, USER_GROUP), | ||
(OH_MY_ZSH_PATH + '/custom/plugins/zsh-autosuggestions', USER_NAME, USER_GROUP), | ||
(OH_MY_ZSH_PATH + '/custom/themes/powerlevel10k', USER_NAME, USER_GROUP), | ||
]) | ||
def test_copied_directories(host, path, user, group): | ||
file = host.file(path) | ||
|
||
assert file.is_directory | ||
assert len(file.listdir()) > 0 | ||
assert file.user == user | ||
assert file.group == group | ||
|
||
|
||
@pytest.mark.parametrize('path,user,group', [ | ||
(HOME_PATH + '/.zshrc', USER_NAME, USER_GROUP), | ||
(HOME_PATH + '/.p10k.zsh', USER_NAME, USER_GROUP), | ||
(HOME_PATH + '/.oh-my-zsh/custom/aliases.zsh', USER_NAME, USER_GROUP), | ||
(FONTS_PATH + '/Fura Code Light Nerd Font Complete.ttf', ROOT, ROOT), | ||
(FONTS_PATH + '/Fura Code Regular Nerd Font Complete.ttf', ROOT, ROOT), | ||
(FONTS_PATH + '/Fura Code Medium Nerd Font Complete.ttf', ROOT, ROOT), | ||
(FONTS_PATH + '/Fura Code Bold Nerd Font Complete.ttf', ROOT, ROOT), | ||
(FONTS_PATH + '/Fura Code Retina Nerd Font Complete.ttf', ROOT, ROOT), | ||
]) | ||
def test_copied_files(host, path, user, group): | ||
file = host.file(path) | ||
|
||
assert file.is_file | ||
assert file.user == user | ||
assert file.group == group | ||
|
||
|
||
def test_zsh(host): | ||
cmd = host.run("zsh") | ||
|
||
assert cmd.succeeded |