Skip to content

Commit

Permalink
add unitest - add to former commit
Browse files Browse the repository at this point in the history
Signed-off-by: Raziel Cohen <rcohen@armosec.io>
  • Loading branch information
Raziel Cohen committed May 1, 2023
1 parent c9a7d26 commit 7a0d5ff
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/conthandler/container_main_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"path"
"sniffer/pkg/config"
configV1 "sniffer/pkg/config/v1"
conthadlerV1 "sniffer/pkg/conthandler/v1"
conthandlerV1 "sniffer/pkg/conthandler/v1"
accumulator "sniffer/pkg/event_data_storage"
"sniffer/pkg/sbom"
Expand Down Expand Up @@ -55,12 +54,12 @@ func TestContMainHandler(t *testing.T) {
RedisInstanceID.SetKind("deployment")
RedisInstanceID.SetName("redis")
RedisInstanceID.SetContainerName("redis")
contHandler.containersEventChan <- *conthadlerV1.CreateNewContainerEvent(RedisImageID, RedisContainerIDContHandler, RedisPodName, RedisWLID, &RedisInstanceID, conthadlerV1.ContainerRunning)
contHandler.containersEventChan <- *conthandlerV1.CreateNewContainerEvent(RedisImageID, RedisContainerIDContHandler, RedisPodName, RedisWLID, &RedisInstanceID, conthandlerV1.ContainerRunning)
}()

event := <-contHandler.containersEventChan
if event.GetContainerEventType() != conthadlerV1.ContainerRunning {
t.Fatalf("event container type is wrong, get: %s expected: %s", event.GetContainerEventType(), conthadlerV1.ContainerRunning)
if event.GetContainerEventType() != conthandlerV1.ContainerRunning {
t.Fatalf("event container type is wrong, get: %s expected: %s", event.GetContainerEventType(), conthandlerV1.ContainerRunning)
}
if event.GetContainerID() != RedisContainerIDContHandler {
t.Fatalf("container ID is wrong, get: %s expected: %s", event.GetContainerID(), RedisContainerIDContHandler)
Expand Down Expand Up @@ -105,7 +104,7 @@ func TestContMainHandlerStopMonitorAfterXMinutes(t *testing.T) {
RedisInstanceID.SetKind("deployment")
RedisInstanceID.SetName("redis")
RedisInstanceID.SetContainerName("redis")
contEvent := conthandlerV1.CreateNewContainerEvent(RedisImageID, RedisContainerIDContHandler, RedisWLID, RedisPodName, &RedisInstanceID, conthadlerV1.ContainerRunning)
contEvent := conthandlerV1.CreateNewContainerEvent(RedisImageID, RedisContainerIDContHandler, RedisWLID, RedisPodName, &RedisInstanceID, conthandlerV1.ContainerRunning)

newWatchedContainer := watchedContainerData{
containerAggregator: CreateAggregator(getShortContainerID(contEvent.GetContainerID())),
Expand Down

0 comments on commit 7a0d5ff

Please sign in to comment.