2020-05-19 11:21:56 +01:00
|
|
|
// Copyright (C) 2020 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information
|
|
|
|
|
|
|
|
package testplanet_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
|
|
"storj.io/common/testcontext"
|
|
|
|
"storj.io/storj/private/testplanet"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSatellite_AddProject(t *testing.T) {
|
|
|
|
testplanet.Run(t, testplanet.Config{
|
|
|
|
SatelliteCount: 1, StorageNodeCount: 0, UplinkCount: 0,
|
|
|
|
}, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) {
|
|
|
|
user, err := planet.Satellites[0].AddUser(ctx, "test user", "test-email@test", 4)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2020-07-15 17:49:37 +01:00
|
|
|
limit, err := planet.Satellites[0].DB.Console().Users().GetProjectLimit(ctx, user.ID)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, 4, limit)
|
|
|
|
|
2020-05-19 11:21:56 +01:00
|
|
|
for i := 0; i < 4; i++ {
|
|
|
|
_, err = planet.Satellites[0].AddProject(ctx, user.ID, "test project "+strconv.Itoa(i))
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
projects, err := planet.Satellites[0].DB.Console().Projects().GetByUserID(ctx, user.ID)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
require.Equal(t, 4, len(projects))
|
|
|
|
|
|
|
|
// test if adding over limit will end with error
|
|
|
|
_, err = planet.Satellites[0].AddProject(ctx, user.ID, "test project over limit")
|
|
|
|
require.Error(t, err)
|
|
|
|
})
|
|
|
|
}
|