|
| 1 | +import HiveSQL from '../../../../src/parser/hive'; |
| 2 | +import { readSQL } from '../../../helper'; |
| 3 | + |
| 4 | +const parser = new HiveSQL(); |
| 5 | + |
| 6 | +const features = { |
| 7 | + databases: readSQL(__dirname, 'createDatabase.sql'), |
| 8 | + tables: readSQL(__dirname, 'createTable.sql'), |
| 9 | + views: readSQL(__dirname, 'createView.sql'), |
| 10 | + functions: readSQL(__dirname, 'createFunction.sql'), |
| 11 | + roles: readSQL(__dirname, 'createRole.sql'), |
| 12 | + indexes: readSQL(__dirname, 'createIndex.sql'), |
| 13 | + macros: readSQL(__dirname, 'createMacro.sql'), |
| 14 | + connectors: readSQL(__dirname, 'createConnector.sql'), |
| 15 | + scheduledQueries: readSQL(__dirname, 'createScheduledQuery.sql') |
| 16 | +}; |
| 17 | + |
| 18 | +describe('Hive Create Syntax Tests', () => { |
| 19 | + describe('CREATE DATABASE', () => { |
| 20 | + features.databases.forEach((database) => { |
| 21 | + it(database, () => { |
| 22 | + expect(parser.validate(database).length).toBe(0); |
| 23 | + }); |
| 24 | + }); |
| 25 | + }); |
| 26 | + |
| 27 | + describe('CREATE TABLE', () => { |
| 28 | + features.tables.forEach((table) => { |
| 29 | + it(table, () => { |
| 30 | + expect(parser.validate(table).length).toBe(0); |
| 31 | + }); |
| 32 | + }); |
| 33 | + }); |
| 34 | + |
| 35 | + describe('CREATE VIEW', () => { |
| 36 | + features.views.forEach((view) => { |
| 37 | + it(view, () => { |
| 38 | + expect(parser.validate(view).length).toBe(0); |
| 39 | + }); |
| 40 | + }); |
| 41 | + }); |
| 42 | + |
| 43 | + describe('CREATE FUNCTION', () => { |
| 44 | + features.functions.forEach((func) => { |
| 45 | + it(func, () => { |
| 46 | + expect(parser.validate(func).length).toBe(0); |
| 47 | + }); |
| 48 | + }); |
| 49 | + }); |
| 50 | + |
| 51 | + describe('CREATE ROLE', () => { |
| 52 | + features.roles.forEach((role) => { |
| 53 | + it(role, () => { |
| 54 | + expect(parser.validate(role).length).toBe(0); |
| 55 | + }); |
| 56 | + }); |
| 57 | + }); |
| 58 | + |
| 59 | + // describe('CREATE INDEX', () => { |
| 60 | + // features.indexes.forEach((index) => { |
| 61 | + // it(index, () => { |
| 62 | + // expect(parser.validate(index).length).toBe(0); |
| 63 | + // }); |
| 64 | + // }); |
| 65 | + // }); |
| 66 | + |
| 67 | + describe('CREATE MACRO', () => { |
| 68 | + features.macros.forEach((macro) => { |
| 69 | + it(macro, () => { |
| 70 | + expect(parser.validate(macro).length).toBe(0); |
| 71 | + }); |
| 72 | + }); |
| 73 | + }); |
| 74 | + |
| 75 | + describe('CREATE CONNECTOR', () => { |
| 76 | + features.connectors.forEach((cnctor) => { |
| 77 | + it(cnctor, () => { |
| 78 | + expect(parser.validate(cnctor).length).toBe(0); |
| 79 | + }); |
| 80 | + }); |
| 81 | + }); |
| 82 | + |
| 83 | + describe('CREATE SCHEDULE QUERY', () => { |
| 84 | + features.scheduledQueries.forEach((sq) => { |
| 85 | + it(sq, () => { |
| 86 | + expect(parser.validate(sq).length).toBe(0); |
| 87 | + }); |
| 88 | + }); |
| 89 | + }); |
| 90 | +}); |
0 commit comments