mirror of
https://github.com/openziti/zrok.git
synced 2024-12-22 23:02:52 +01:00
fix limitclass creation in test (#606)
This commit is contained in:
parent
e2a55393a5
commit
7b8c9483e7
@ -3,15 +3,8 @@ package limits
|
||||
import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/openziti/zrok/controller/store"
|
||||
"github.com/openziti/zrok/sdk/golang/sdk"
|
||||
)
|
||||
|
||||
type UserLimits struct {
|
||||
resource store.ResourceCountClass
|
||||
bandwidth store.BandwidthClass
|
||||
scopes map[sdk.BackendMode]store.BandwidthClass
|
||||
}
|
||||
|
||||
type AccountAction interface {
|
||||
HandleAccount(a *store.Account, rxBytes, txBytes int64, limit store.BandwidthClass, trx *sqlx.Tx) error
|
||||
}
|
||||
|
17
controller/limits/userLimits.go
Normal file
17
controller/limits/userLimits.go
Normal file
@ -0,0 +1,17 @@
|
||||
package limits
|
||||
|
||||
import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/openziti/zrok/controller/store"
|
||||
"github.com/openziti/zrok/sdk/golang/sdk"
|
||||
)
|
||||
|
||||
type userLimits struct {
|
||||
resource store.ResourceCountClass
|
||||
bandwidth store.BandwidthClass
|
||||
scopes map[sdk.BackendMode]store.BandwidthClass
|
||||
}
|
||||
|
||||
func (a *Agent) getUserLimits(acctId int, trx *sqlx.Tx) (*userLimits, error) {
|
||||
return nil, nil
|
||||
}
|
@ -37,15 +37,18 @@ func TestBandwidthLimitJournal(t *testing.T) {
|
||||
assert.Equal(t, int64(1024), latestJe.RxBytes)
|
||||
assert.Equal(t, int64(2048), latestJe.TxBytes)
|
||||
|
||||
lcId, err := str.CreateLimitClass(&LimitClass{
|
||||
ShareMode: sdk.PrivateShareMode,
|
||||
BackendMode: sdk.VpnBackendMode,
|
||||
lc := &LimitClass{
|
||||
ShareMode: new(sdk.ShareMode),
|
||||
BackendMode: new(sdk.BackendMode),
|
||||
PeriodMinutes: 60,
|
||||
RxBytes: 4096,
|
||||
TxBytes: 8192,
|
||||
TotalBytes: 10240,
|
||||
LimitAction: LimitLimitAction,
|
||||
}, trx)
|
||||
}
|
||||
*lc.ShareMode = sdk.PrivateShareMode
|
||||
*lc.BackendMode = sdk.ProxyBackendMode
|
||||
lcId, err := str.CreateLimitClass(lc, trx)
|
||||
assert.NoError(t, err)
|
||||
|
||||
_, err = str.CreateBandwidthLimitJournalEntry(&BandwidthLimitJournalEntry{AccountId: acctId, LimitClassId: &lcId, Action: LimitLimitAction, RxBytes: 10240, TxBytes: 20480}, trx)
|
||||
|
Loading…
Reference in New Issue
Block a user