<commit_before>var assert = require('assert');
var King = require('../lib')
describe('King', function(){
	describe('~hosts', function(){
		describe('#url', function(){
			var k1, k2
			before( function(){
				k1 = new King()
				k2 = new King({
					hosts:[
						'http://localhost:8001',
						'http://localhost:8002'
					]
				})
			})
			it('should accept a single url', function(){
				assert.equal(k1.url(), 'http://localhost:8001/')
				assert.equal(k1.url(), 'http://localhost:8001/')
			});

			it('should accept a resource parameter', function(){
				assert.equal(k1.url('test'), 'http://localhost:8001/test')
			})

			it('should accept a resource and id parameter', function(){
				assert.equal(k1.url('test', 1), 'http://localhost:8001/test/1')
			})

			it('should cycle through an array of host urls', function(){
				var first = k2.url().replace(/\/$/,'')
				  , second
				  ;
				assert.notEqual(k2.options.hosts.indexOf( first, -1 ) )
				second = k2.url().replace(/\/$/, '')
				assert.notEqual( first, second )
				assert.notEqual(k2.options.hosts.indexOf( second, -1 ) )
			})
		})
	});
});<commit_msg>tests for auto create apis<commit_after>var assert = require('assert');
var King = require('../lib')
describe('King', function(){
	describe('~hosts', function(){
		describe('#url', function(){
			var k1, k2
			before( function(){
				k1 = new King()
				k2 = new King({
					hosts:[
						'http://localhost:8001',
						'http://localhost:8002'
					]
				})
			})
			it('should accept a single url', function(){
				assert.equal(k1.url(), 'http://localhost:8001/')
				assert.equal(k1.url(), 'http://localhost:8001/')
			});

			it('should accept a resource parameter', function(){
				assert.equal(k1.url('test'), 'http://localhost:8001/test')
			})

			it('should accept a resource and id parameter', function(){
				assert.equal(k1.url('test', 1), 'http://localhost:8001/test/1')
			})

			it('should cycle through an array of host urls', function(){
				var first = k2.url().replace(/\/$/,'')
				  , second
				  ;
			
                assert.notEqual(k2.options.hosts.indexOf( first, -1 ) )
				second = k2.url().replace(/\/$/, '')
				assert.notEqual( first, second )
				assert.notEqual(k2.options.hosts.indexOf( second, -1 ) )
			})
		});
	});

    describe('~apis', function( ){
        var k1;
        before(function( done ){
            k1 = new King({
                apis:[{
                    name:'__test',
                    upstream_url:'http://localhost:9000',
                    request_path:'/test',
                    strip_request_path:true,
                    request_path:'/test'
                }]
            });
            done();
        });
        
        after( function( done ){
            k1
                .destroy('apis','__test')
                .then( done.bind(null,null) )
                .catch( done ); 
        });
        
        it('should auto create an api', function( done ){
            k1.list('apis').then( function( ls ){
               assert.ok( ls.length );
               assert.equal(1, ls.filter( function(i){return i.name === '__test'}).length);
               done();
            });

        });
    });
});
{'fraction_non_alphanumeric': 0.1876365906962223, 'fraction_numerical': 0.02778645020293475, 'mean_word_length': 2.101645692158761, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5478363', 'n_tokens_mistral': 1216, 'n_tokens_neox': 973, 'n_words': 205}