Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DimmaDont committed Jan 11, 2025
1 parent 79e73ae commit 7dfb2b3
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 15 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ jobs:

- run: npm i conf

- name: Generate conf output
run: node tests/main.mjs

- name: Run Tests
shell: bash
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ dist/
**/*.egg-info/
node_modules/

package.json
package-lock.json

config.json
config_plaintext.json
key.txt
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"python.testing.unittestArgs": [
"-v",
"-s",
"./tests",
"-p",
"test_*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This Python library encrypts/decrypts [`sindresorhus/conf`](https://github.com/s

## Installation
```bash
pip install git+https://github.com/DimmaDont/py-crypt-sindresorhus-conf@1.0.1
pip install git+https://github.com/DimmaDont/py-crypt-sindresorhus-conf
```

## Usage example
Expand Down
21 changes: 10 additions & 11 deletions tests/main.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import fs from 'node:fs'
import fs from "node:fs";

import Conf from 'conf'
import Conf from "conf";


const key = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
fs.writeFileSync('./key.txt', key)
const key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
fs.writeFileSync("./key.txt", key);

const config = new Conf({
projectName: 'foo',
cwd: './',
encryptionKey: key,
})
config.set({"c": 1, "b": 2, "a": 3})
projectName: "foo",
cwd: "./",
encryptionKey: key,
});
config.set({ c: 1, b: 2, a: 3 });

fs.writeFileSync('./config_plaintext.json', config._serialize(config.store));
fs.writeFileSync("./config_plaintext.json", config._serialize(config.store));
9 changes: 9 additions & 0 deletions tests/test_crypt_sindresorhus_conf.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import json
import os
import subprocess
import unittest

from src.crypt_sindresorhus_conf import CryptSindresorhusConf


class TestCryptSindresorhusConf(unittest.TestCase):
def setUp(self):
subprocess.run(["node", "tests/main.mjs"], check=True)

with open("key.txt", "rb") as f:
key = f.read()

Expand All @@ -31,3 +35,8 @@ def test_json(self):
self.assertEqual(data["c"], 1)
self.assertEqual(data["b"], 2)
self.assertEqual(data["a"], 3)

def tearDown(self):
os.remove("key.txt")
os.remove("config.json")
os.remove("config_plaintext.json")

0 comments on commit 7dfb2b3

Please sign in to comment.