@@ -6,7 +6,6 @@ import io.airbyte.config.FieldType
6
6
import io.airbyte.config.StreamDescriptor
7
7
import io.airbyte.config.adapters.TestRecordAdapter
8
8
import io.airbyte.mappers.transformations.HashingMapper.Companion.supportedMethods
9
- import io.mockk.every
10
9
import io.mockk.spyk
11
10
import org.junit.jupiter.api.Assertions.assertEquals
12
11
import org.junit.jupiter.api.Assertions.assertFalse
@@ -86,18 +85,17 @@ class HashingMapperTest {
86
85
" test" ,
87
86
mapOf (
88
87
HashingMapper .TARGET_FIELD_CONFIG_KEY to " field1" ,
89
- HashingMapper .METHOD_CONFIG_KEY to HashingMapper . SHA256 ,
88
+ HashingMapper .METHOD_CONFIG_KEY to hashingMethod ,
90
89
HashingMapper .FIELD_NAME_SUFFIX_CONFIG_KEY to " _hashed" ,
91
90
),
92
91
)
93
92
94
- every { hashingMapper.hashAndEncodeData(HashingMapper .SHA256 , " value1" .toByteArray()) } returns " hashed_value"
95
-
96
93
val record = TestRecordAdapter (StreamDescriptor ().withName(" stream" ), mapOf (" field1" to " value1" , " field2" to " value2" ))
97
94
hashingMapper.map(config, record)
98
95
99
96
assertTrue(record.has(" field1_hashed" ))
100
- assertEquals(" hashed_value" , record.get(" field1_hashed" ).asString())
97
+ val hashedValue = record.get(" field1_hashed" ).asString()
98
+ assertTrue(" hashed_value" != hashedValue && hashedValue.all { it.isLetterOrDigit() }, " $hashedValue doesn't look like a valid hash" )
101
99
assertFalse(record.has(" field1" ))
102
100
assertTrue(record.has(" field2" ))
103
101
assertEquals(" value2" , record.get(" field2" ).asString())
0 commit comments