forked from RedHatInsights/vuln4shift-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport_test.go
49 lines (42 loc) · 1.34 KB
/
export_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package digestwriter
import (
"app/base/utils"
)
// Export for testing
//
// This source file contains name aliases of all package-private functions
// that need to be called from unit tests. Aliases should start with uppercase
// letter because unit tests belong to different package.
//
// Please look into the following blogpost:
// https://medium.com/@robiplus/golang-trick-export-for-test-aa16cbd7b8cd
// to see why this trick is needed.
var (
// functions from consumer.go source file
ExtractDigestsFromMessage = extractDigestsFromMessage
ParseMessage = parseMessage
)
// kafka-related functions
// NewDummyConsumerWithProcessor has the same arguments as NewConsumer
// but returns a non-configured utils.KafkaConsumer and the DigestConsumer object for testing purposes
func NewDummyConsumerWithProcessor(storage Storage) (*utils.KafkaConsumer, *DigestConsumer) {
processor := DigestConsumer{
storage,
0,
nil,
}
consumer := utils.KafkaConsumer{
Processor: &processor,
}
return &consumer, &processor
}
// storage-related functions
func LinkDigestsToCluster(s *DBStorage, clusterStr string, clusterID, archID int64, digests []string) error {
tx := s.connection.Begin()
defer tx.Rollback()
err := s.linkDigestsToCluster(tx, clusterStr, clusterID, archID, digests)
if err != nil {
return err
}
return tx.Commit().Error
}