Fix tests

This commit is contained in:
braginini
2022-12-27 17:48:00 +01:00
parent 6143aeef35
commit 7cf9ab71f2
7 changed files with 25 additions and 21 deletions

View File

@@ -3,7 +3,7 @@ package server
import (
"fmt"
nbdns "github.com/netbirdio/netbird/dns"
"github.com/netbirdio/netbird/management/server/activity"
activity "github.com/netbirdio/netbird/management/server/activity/sqlite"
"github.com/netbirdio/netbird/route"
"net"
"reflect"

View File

@@ -165,6 +165,26 @@ type Store interface {
Close() error
}
// NoopEventStore implements the Store interface without doing any operations
type NoopEventStore struct {
}
// Save sets the Event.ID to 1
func (store *NoopEventStore) Save(event *Event) (*Event, error) {
event.ID = 1
return event, nil
}
// Get returns an empty list of events
func (store *NoopEventStore) Get(accountID string, offset, limit int, descending bool) ([]*Event, error) {
return []*Event{}, nil
}
// Close doesn't close anything
func (store *NoopEventStore) Close() error {
return nil
}
// Event represents a network/system activity event.
type Event struct {
// Timestamp of the event

View File

@@ -1,17 +1 @@
package activity
type NoopEventStore struct {
}
func (store *NoopEventStore) Save(event *Event) (*Event, error) {
event.ID = 1
return event, nil
}
func (store *NoopEventStore) Get(accountID string, offset, limit int, descending bool) ([]*Event, error) {
return []*Event{}, nil
}
func (store *NoopEventStore) Close() error {
return nil
}

View File

@@ -3,7 +3,7 @@ package server
import (
"context"
"fmt"
"github.com/netbirdio/netbird/management/server/activity"
activity "github.com/netbirdio/netbird/management/server/activity/sqlite"
"net"
"os"
"path/filepath"

View File

@@ -2,7 +2,7 @@ package server_test
import (
"context"
"github.com/netbirdio/netbird/management/server/activity"
activity "github.com/netbirdio/netbird/management/server/activity/sqlite"
"math/rand"
"net"
"os"

View File

@@ -2,7 +2,7 @@ package server
import (
nbdns "github.com/netbirdio/netbird/dns"
"github.com/netbirdio/netbird/management/server/activity"
activity "github.com/netbirdio/netbird/management/server/activity/sqlite"
"github.com/stretchr/testify/require"
"net/netip"
"testing"

View File

@@ -1,7 +1,7 @@
package server
import (
"github.com/netbirdio/netbird/management/server/activity"
activity "github.com/netbirdio/netbird/management/server/activity/sqlite"
"github.com/netbirdio/netbird/route"
"github.com/rs/xid"
"github.com/stretchr/testify/require"