You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
2.6 KiB
99 lines
2.6 KiB
import { connectionCanEdit, resolveUrlInfo, splitUrl, getJdbcDatabaseType } from '../app.service'; |
|
const connection = { |
|
connectionId: '', |
|
connectionType: '', |
|
connectionName: '', |
|
connectionData: '', |
|
}; |
|
|
|
/** |
|
* test_author_alan |
|
*/ |
|
test('DEC-11030 拼接url', () => { |
|
expect(splitUrl('localhost', '22', 'dbname', 'jdbc:pivotal:greenplum://hostname:port;dbname')).toEqual('jdbc:pivotal:greenplum://localhost:22;dbname'); |
|
}); |
|
/** |
|
* test_author_alan |
|
*/ |
|
test('BI-56355 如果数据库类型和驱动都为空,则为其他jdbc', () => { |
|
expect(getJdbcDatabaseType('', '').databaseType).toEqual('otherJDBC'); |
|
expect(getJdbcDatabaseType('mysql', '').databaseType).toEqual('mysql'); |
|
expect(getJdbcDatabaseType('', 'com.mysql.jdbc.Driver').databaseType).toEqual('mysql'); |
|
}); |
|
|
|
/** |
|
* test_author_alan |
|
*/ |
|
test('DEC-10992 数据连接名称带-', () => { |
|
expect(resolveUrlInfo('jdbc:sqlserver://192.168.17.111:1433;databaseName=L-Pick-DAS-MengYan')).toEqual({ |
|
host: '192.168.17.111', |
|
port: '1433', |
|
databaseName: 'L-Pick-DAS-MengYan', |
|
urlInfo: '', |
|
}); |
|
}); |
|
|
|
test('解析url', () => { |
|
expect(resolveUrlInfo('jdbc:postgresql://endpoint:port/database')).toEqual({ |
|
host: 'endpoint', |
|
port: '', |
|
databaseName: 'database', |
|
urlInfo: '', |
|
}); |
|
expect(resolveUrlInfo('jdbc:pivotal:greenplum://hostname:port;dbname')).toEqual({ |
|
host: 'hostname', |
|
port: '', |
|
databaseName: 'dbname', |
|
urlInfo: '', |
|
}); |
|
expect(resolveUrlInfo('jdbc:mysql://hostname:22/database')).toEqual({ |
|
host: 'hostname', |
|
port: '22', |
|
databaseName: 'database', |
|
urlInfo: '', |
|
}); |
|
}); |
|
|
|
/** |
|
* test_author_alan |
|
*/ |
|
test('BI-51537 判断数据连接是否有权限', () => { |
|
expect(connectionCanEdit({ |
|
...connection, |
|
})).toEqual(true); |
|
|
|
expect(connectionCanEdit({ |
|
...connection, |
|
privilegeDetailBeanList: null, |
|
})).toEqual(true); |
|
|
|
expect(connectionCanEdit({ |
|
...connection, |
|
privilegeDetailBeanList: [ |
|
{ |
|
privilegeType: 4, |
|
privilegeValue: 2, |
|
}, |
|
], |
|
})).toEqual(true); |
|
|
|
expect(connectionCanEdit({ |
|
...connection, |
|
privilegeDetailBeanList: [ |
|
{ |
|
privilegeType: 4, |
|
privilegeValue: 1, |
|
}, |
|
], |
|
})).toEqual(false); |
|
|
|
expect(connectionCanEdit({ |
|
...connection, |
|
privilegeDetailBeanList: [ |
|
{ |
|
privilegeType: 2, |
|
privilegeValue: 1, |
|
}, |
|
], |
|
})).toEqual(false); |
|
});
|
|
|