|
| 1 | +/* groovylint-disable MethodName */ |
| 2 | +/* |
| 3 | + * Copyright 2025, Quilt Data Inc |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | +package nextflow.quilt.jep |
| 18 | + |
| 19 | +import com.quiltdata.quiltcore.Entry |
| 20 | +import nextflow.quilt.QuiltSpecification |
| 21 | +import spock.lang.Specification |
| 22 | + |
| 23 | +/** |
| 24 | + * Test hash type support in quiltcore Entry class |
| 25 | + * |
| 26 | + * @author Ernest Prabhakar <ernest@quiltdata.io> |
| 27 | + */ |
| 28 | +class QuiltHashTypeTest extends Specification { |
| 29 | + |
| 30 | + def 'should parse SHA256 hash type'() { |
| 31 | + when: |
| 32 | + def result = Entry.HashType.enumFor('SHA256') |
| 33 | + |
| 34 | + then: |
| 35 | + result == Entry.HashType.SHA256 |
| 36 | + } |
| 37 | + |
| 38 | + def 'should parse sha2-256-chunked hash type'() { |
| 39 | + when: |
| 40 | + def result = Entry.HashType.enumFor('sha2-256-chunked') |
| 41 | + |
| 42 | + then: |
| 43 | + result == Entry.HashType.SHA2_256_Chunked |
| 44 | + } |
| 45 | + |
| 46 | + def 'should handle case-insensitive hash type names'() { |
| 47 | + when: |
| 48 | + def result1 = Entry.HashType.enumFor('sha256') |
| 49 | + def result2 = Entry.HashType.enumFor('SHA256') |
| 50 | + def result3 = Entry.HashType.enumFor('Sha256') |
| 51 | + |
| 52 | + then: |
| 53 | + result1 == Entry.HashType.SHA256 |
| 54 | + result2 == Entry.HashType.SHA256 |
| 55 | + result3 == Entry.HashType.SHA256 |
| 56 | + } |
| 57 | + |
| 58 | + def 'should handle different separator formats for chunked'() { |
| 59 | + when: |
| 60 | + def result1 = Entry.HashType.enumFor('sha2-256-chunked') |
| 61 | + def result2 = Entry.HashType.enumFor('SHA2_256_Chunked') |
| 62 | + def result3 = Entry.HashType.enumFor('sha2_256_chunked') |
| 63 | + |
| 64 | + then: |
| 65 | + result1 == Entry.HashType.SHA2_256_Chunked |
| 66 | + result2 == Entry.HashType.SHA2_256_Chunked |
| 67 | + result3 == Entry.HashType.SHA2_256_Chunked |
| 68 | + } |
| 69 | + |
| 70 | + def 'should throw IllegalArgumentException for unknown hash type'() { |
| 71 | + when: |
| 72 | + Entry.HashType.enumFor('invalid-hash-type') |
| 73 | + |
| 74 | + then: |
| 75 | + thrown(IllegalArgumentException) |
| 76 | + } |
| 77 | +} |
0 commit comments