Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
Initialize project
Browse files Browse the repository at this point in the history
  • Loading branch information
malkoG committed Apr 9, 2023
0 parents commit 21602a9
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
TESTS_INIT=tests/minimal_init.lua
TESTS_DIR=tests/

.EXPORT_ALL_VARIABLES:

PROJECT_ENV = test

.PHONY: test

test:
@nvim \
--headless \
--noplugin \
-u ${TESTS_INIT} \
-c "PlenaryBustedDirectory ${TESTS_DIR} { minimal_init = '${TESTS_INIT}' }"
14 changes: 14 additions & 0 deletions tests/minimal_init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
local plenary_dir = os.getenv("PLENARY_DIR") or "/tmp/plenary.nvim"
local is_not_a_directory = vim.fn.isdirectory(plenary_dir) == 0
if is_not_a_directory then
vim.fn.system({ "git", "clone", "https://github.com/nvim-lua/plenary.nvim", plenary_dir })
end

vim.opt.rtp:append(".")
vim.opt.rtp:append(plenary_dir)

vim.cmd("runtime plugin/plenary.vim")
require("plenary.busted")


-- please ensure that lua-openssl is installed via luarocks
17 changes: 17 additions & 0 deletions tests/vault/utils_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
local cipher = require('openssl').cipher

describe('utils', function()
it("encryption is successful", function()
local original = {
env = { OPEN_API_KEY = "blahblahblah" }
}
local cipher_algorithm = "aes-128-cbc"
local json_encoded = vim.fn.json_encode(original)
local encryption_key = "aaabbb111"
local encrypted_content = cipher.encrypt(cipher_algorithm, json_encoded, encryption_key)
local decrypted_content = cipher.decrypt(cipher_algorithm, encrypted_content, encryption_key)
assert(json_encoded == decrypted_content)
end)
end)


0 comments on commit 21602a9

Please sign in to comment.