<commit_before>require!<[fs fs-extra js-yaml path tmp]>
expect = require \chai .expect

app = require \..

describe 'config', (,) !->
    before !->
        app.logger.initWinston!

    describe 'set-account', (,) !->

        it 'set account, no password, config absence', (done) !->
            (err, dir, cb) <-! tmp.dir do
                unsafeCleanup: true

            if err
                throw err

            cfg-path = path.join dir, \set-account-no-password-config-absense.yaml
            username = \this-is-username

            app.config.set-account username, do
                _cfg-path: cfg-path

            cfg = js-yaml.safeLoad fs.readFileSync cfg-path, \utf-8

            expect cfg .to.deep.equal do
                account:
                    username: username

            cb!
            done!

        it 'set account, with password, config absence', (done) !->
            (err, dir, cb) <-! tmp.dir do
                unsafeCleanup: true

            if err
                throw err

            cfg-path = path.join dir, \set-account-with-password-config-absense.yaml
            username = \this-is-username
            password = <PASSWORD>

            app.config.set-account username, do
                password: password
                _cfg-path: cfg-path

            cfg = js-yaml.safeLoad fs.readFileSync cfg-path, \utf-8

            expect cfg .to.deep.equal do
                account:
                    username: username
                    password: password

            cb!
            done!

        it 'set account, no password, config present', (done) !->
            (err, dir, cb) <-! tmp.dir do
                unsafeCleanup: true

            if err
                throw err

            original-cfg-path = path.join __dirname, \data \set-account-config.yaml
            cfg-path = path.join dir, \update-exist-account.yaml

            fs-extra.copySync original-cfg-path, cfg-path

            username = \this-is-another-username
            password = <PASSWORD>

            app.config.set-account username, do
                _cfg-path: cfg-path

            cfg = js-yaml.safeLoad fs.readFileSync cfg-path, \utf-8

            expect cfg .to.deep.equal do
                account:
                    username: username
                    password: password

            cb!
            done!

        it 'set account, with password, config present', (done) !->
            (err, dir, cb) <-! tmp.dir do
                unsafeCleanup: true

            if err
                throw err

            original-cfg-path = path.join __dirname, \data \set-account-config.yaml
            cfg-path = path.join dir, \update-exist-account.yaml

            fs-extra.copySync original-cfg-path, cfg-path

            username = \this-is-another-username
            password = \<PASSWORD>

            app.config.set-account username, do
                password: password
                _cfg-path: cfg-path

            cfg = js-yaml.safeLoad fs.readFileSync cfg-path, \utf-8

            expect cfg .to.deep.equal do
                account:
                    username: username
                    password: password

            cb!
            done!

    describe 'get-account', (,) !->

        it 'get account, config absence', (done) !->
            (err, dir, cb) <-! tmp.dir do
                unsafeCleanup: true

            if err
                throw err

            cfg-path = path.join dir, \get-account.yaml

            account = app.config.get-account do
                _cfg-path: cfg-path

            expect account .to.deep.equal {}

            cb!
            done!<commit_msg>Implement test case for set-account-uid<commit_after>require!<[fs fs-extra js-yaml path tmp]>
expect = require \chai .expect

app = require \..

describe 'config', (,) !->
    before !->
        app.logger.initWinston!

    describe 'set-account', (,) !->

        it 'set account, no password, config absence', (done) !->
            (err, dir, cb) <-! tmp.dir do
                unsafeCleanup: true

            if err
                throw err

            cfg-path = path.join dir, \set-account-no-password-config-absense.yaml
            username = \this-is-username

            app.config.set-account username, do
                _cfg-path: cfg-path

            cfg = js-yaml.safeLoad fs.readFileSync cfg-path, \utf-8

            expect cfg .to.deep.equal do
                account:
                    username: username

            cb!
            done!

        it 'set account, with password, config absence', (done) !->
            (err, dir, cb) <-! tmp.dir do
                unsafeCleanup: true

            if err
                throw err

            cfg-path = path.join dir, \set-account-with-password-config-absense.yaml
            username = \this-is-username
            password = \<PASSWORD>

            app.config.set-account username, do
                password: password
                _cfg-path: cfg-path

            cfg = js-yaml.safeLoad fs.readFileSync cfg-path, \utf-8

            expect cfg .to.deep.equal do
                account:
                    username: username
                    password: password

            cb!
            done!

        it 'set account, no password, config present', (done) !->
            (err, dir, cb) <-! tmp.dir do
                unsafeCleanup: true

            if err
                throw err

            original-cfg-path = path.join __dirname, \data \set-account-config.yaml
            cfg-path = path.join dir, \update-exist-account.yaml

            fs-extra.copySync original-cfg-path, cfg-path

            username = \this-is-another-username
            password = <PASSWORD>

            app.config.set-account username, do
                _cfg-path: cfg-path

            cfg = js-yaml.safeLoad fs.readFileSync cfg-path, \utf-8

            expect cfg .to.deep.equal do
                account:
                    username: username
                    password: password

            cb!
            done!

        it 'set account, with password, config present', (done) !->
            (err, dir, cb) <-! tmp.dir do
                unsafeCleanup: true

            if err
                throw err

            original-cfg-path = path.join __dirname, \data \set-account-config.yaml
            cfg-path = path.join dir, \update-exist-account.yaml

            fs-extra.copySync original-cfg-path, cfg-path

            username = \this-is-another-username
            password = <PASSWORD>

            app.config.set-account username, do
                password: password
                _cfg-path: cfg-path

            cfg = js-yaml.safeLoad fs.readFileSync cfg-path, \utf-8

            expect cfg .to.deep.equal do
                account:
                    username: username
                    password: password

            cb!
            done!

    describe 'get-account', (,) !->

        it 'get account, config absence', (done) !->
            (err, dir, cb) <-! tmp.dir do
                unsafeCleanup: true

            if err
                throw err

            cfg-path = path.join dir, \get-account.yaml

            account = app.config.get-account do
                _cfg-path: cfg-path

            expect account .to.deep.equal {}

            cb!
            done!

    describe 'set-account-uid', (,) !->

        it 'set account uid, config absense', (done) !->
            (err, dir, tmp-dir-cb) <-! tmp.dir do
                unsafe-cleanup: true

            if err
                throw err

            username = \this-is-username
            uid = 0xdeadbeef

            cfg-path = path.join dir, \set-account-uid.yaml

            (err) <- app.config.set-account-uid username, uid, do
                _cfg-path: cfg-path

            expect err .to.be.null

            (err, res) <- app.config.get-account-uid username, do
                _cfg-path: cfg-path

            expect err .to.be.null

            expect res .to.equal uid

            tmp-dir-cb!
            done!

        it 'set account uid, config present', (done) !->
            # FIXME: Implement this
            done!

    describe 'get-account-uid', (,) !->

        it 'get account uid, config absense', (done) !->
            # FIXME: Implement this
            done!

        it 'get account uid, config present', (done) !->
            # FIXME: Implement this
            done!
{'fraction_non_alphanumeric': 0.10004719207173195, 'fraction_numerical': 0.0010618216139688533, 'mean_word_length': 1.239038563127311, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2717892', 'n_tokens_mistral': 2376, 'n_tokens_neox': 2193, 'n_words': 608}