Skip to content

Commit 8247b7f

Browse files
committed
feat(init): tool initialisation
1 parent 458c538 commit 8247b7f

File tree

13 files changed

+1269
-614
lines changed

13 files changed

+1269
-614
lines changed

__tests__/core.test.ts

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import * as core from '../src/core'
2+
import sh from 'shelljs'
3+
4+
describe('testing core functionalities', () => {
5+
describe('config', () => {
6+
let tempConfigFile: string
7+
8+
test('default config values are defined', () => {
9+
const defaults: core.ConfigValues = core.getDefaultConfigValues()
10+
11+
expect(defaults).toBeDefined()
12+
})
13+
test('default config values contain values', () => {
14+
const defaults: core.ConfigValues = core.getDefaultConfigValues()
15+
16+
expect(defaults.main).toMatch('master')
17+
expect(defaults.usedev).not.toBeTruthy()
18+
expect(defaults.integration).toEqual(1)
19+
})
20+
21+
test('load default values if no config files - part I', () => {
22+
const defaults = core.loadConfigFile()
23+
24+
expect(defaults.main).toMatch('master')
25+
expect(defaults.usedev).not.toBeTruthy()
26+
expect(defaults.integration).toEqual(1)
27+
})
28+
29+
test('load default values if no config files - part II', () => {
30+
const defaults = core.loadConfigValues()
31+
32+
expect(defaults.main).toMatch('master')
33+
expect(defaults.usedev).not.toBeTruthy()
34+
expect(defaults.integration).toEqual(1)
35+
})
36+
37+
test('write default config file', () => {
38+
core.writeConfigFile({})
39+
40+
expect(sh.test('-f', 'gof.config.js')).toBeTruthy()
41+
sh.rm('gof.config.js')
42+
})
43+
44+
test('write to config file', () => {
45+
tempConfigFile = sh.tempdir() + '/gof.test.config.json'
46+
47+
core.writeConfigFile({
48+
file: tempConfigFile,
49+
data: { test: 'test value' }
50+
})
51+
52+
expect(sh.test('-f', tempConfigFile)).toBeTruthy()
53+
})
54+
55+
test('load config values from file', () => {
56+
const defaults = core.loadConfigFile(tempConfigFile)
57+
58+
expect(defaults).toBeDefined()
59+
expect(defaults.test).toMatch('test value')
60+
})
61+
62+
test('write to (and load from) .js file', () => {
63+
const jsFile = sh.tempdir() + '/gof.config.js'
64+
65+
core.writeConfigFile({
66+
file: jsFile,
67+
data: { development: 'develop', test: true }
68+
})
69+
70+
expect(sh.test('-f', jsFile)).toBeTruthy()
71+
72+
const jsObject = core.loadConfigFile(jsFile)
73+
74+
expect(jsObject.development).toMatch('develop')
75+
expect(jsObject.test).toBeTruthy()
76+
})
77+
78+
test('attemp to write to wrong file type', () => {
79+
const wrong = core.writeConfigFile({ file: 'file.wrong' })
80+
81+
expect(wrong).not.toBeTruthy()
82+
})
83+
})
84+
85+
describe('git', () => {
86+
test('the branch name is valid', () => {
87+
expect(core.isValidBranchName('branch/name')).toBeTruthy()
88+
})
89+
test('the branch name is invalid', () => {
90+
expect(core.isValidBranchName('branch///dkd/.kdk,.l')).not.toBeTruthy()
91+
})
92+
test('the tag name is valid', () => {
93+
expect(core.isValidTagName('1.2.3')).toBeTruthy()
94+
})
95+
test('the tag name is invalid', () => {
96+
expect(core.isValidTagName('1...3.4.5')).not.toBeTruthy()
97+
})
98+
})
99+
})

bin/gof-init.js

Lines changed: 0 additions & 165 deletions
This file was deleted.

0 commit comments

Comments
 (0)