@@ -314,4 +314,46 @@ final class CompileDownTests: XCTestCase {
314314 let compiledQuery = try precompiledQuery. compileToRunnableQuery ( )
315315 XCTAssertEqual ( compiledQuery. dataSource? . name, " some-unknown-namespace " )
316316 }
317+
318+ func testAllowsHourlyGranularityForTimeseries( ) throws {
319+ let intervals : [ QueryTimeInterval ] = [
320+ . init( beginningDate: Date ( iso8601String: " 2023-04-01T00:00:00.000Z " ) !, endDate: Date ( iso8601String: " 2023-05-31T00:00:00.000Z " ) !) ,
321+ ]
322+ let query = CustomQuery ( queryType: . timeseries, intervals: intervals, granularity: . hour)
323+ XCTAssertNoThrow ( try query. precompile ( organizationAppIDs: [ appID1, appID2] , isSuperOrg: false ) )
324+ }
325+
326+ func testAllowsDailyGranularityForTopN( ) throws {
327+ let intervals : [ QueryTimeInterval ] = [
328+ . init( beginningDate: Date ( iso8601String: " 2023-04-01T00:00:00.000Z " ) !, endDate: Date ( iso8601String: " 2023-05-31T00:00:00.000Z " ) !) ,
329+ ]
330+ let query = CustomQuery ( queryType: . topN, intervals: intervals, granularity: . day)
331+ XCTAssertNoThrow ( try query. precompile ( organizationAppIDs: [ appID1, appID2] , isSuperOrg: false ) )
332+ }
333+
334+ func testAllowsDailyGranularityForGroupBy( ) throws {
335+ let intervals : [ QueryTimeInterval ] = [
336+ . init( beginningDate: Date ( iso8601String: " 2023-04-01T00:00:00.000Z " ) !, endDate: Date ( iso8601String: " 2023-05-31T00:00:00.000Z " ) !) ,
337+ ]
338+ let query = CustomQuery ( queryType: . groupBy, intervals: intervals, granularity: . day)
339+ XCTAssertNoThrow ( try query. precompile ( organizationAppIDs: [ appID1, appID2] , isSuperOrg: false ) )
340+ }
341+
342+ func testDisallowsHourlyQueriesForTopN( ) throws {
343+ let intervals : [ QueryTimeInterval ] = [
344+ . init( beginningDate: Date ( iso8601String: " 2023-04-01T00:00:00.000Z " ) !, endDate: Date ( iso8601String: " 2023-05-31T00:00:00.000Z " ) !) ,
345+ ]
346+ let query = CustomQuery ( queryType: . topN, intervals: intervals, granularity: . hour)
347+
348+ XCTAssertThrowsError ( try query. precompile ( organizationAppIDs: [ appID1, appID2] , isSuperOrg: false ) )
349+ }
350+
351+ func testDisallowsHourlyQueriesForGroupBy( ) throws {
352+ let intervals : [ QueryTimeInterval ] = [
353+ . init( beginningDate: Date ( iso8601String: " 2023-04-01T00:00:00.000Z " ) !, endDate: Date ( iso8601String: " 2023-05-31T00:00:00.000Z " ) !) ,
354+ ]
355+ let query = CustomQuery ( queryType: . groupBy, intervals: intervals, granularity: . hour)
356+
357+ XCTAssertThrowsError ( try query. precompile ( organizationAppIDs: [ appID1, appID2] , isSuperOrg: false ) )
358+ }
317359}
0 commit comments