Skip to content
Snippets Groups Projects
Commit 5ea26dec authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

fix tests

parent acc85886
No related branches found
No related tags found
No related merge requests found
......@@ -4,8 +4,6 @@ SOURCE_DIR=$1
OUT_DIR=$2
ASAPO_MINIMUM_COVERAGE=$3
export GOPATH=$GOPATH:$4
echo $OUT_DIR
touch $OUT_DIR/coverage.out
......
......@@ -13,11 +13,6 @@ function(gotest target source_dir test_source_files)
if (BUILD_TESTS)
add_test(NAME test-${target} COMMAND go test ${test_source_files}
WORKING_DIRECTORY ${source_dir})
set_property(
TEST
test-${target}
PROPERTY
ENVIRONMENT "GOPATH=${gopath}")
message(STATUS "Added test 'test-${target}'")
if (CMAKE_COMPILER_IS_GNUCXX)
add_test(NAME coveragetest-${target}
......@@ -29,16 +24,11 @@ function(gotest target source_dir test_source_files)
endif ()
endfunction()
function(go_integration_test target test_source_files label)
function(go_integration_test target source_dir test_source_files label)
if (BUILD_TESTS)
add_test(NAME test-${target} COMMAND go test ${test_source_files} -run ${label}
-tags integration_tests
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set_property(
TEST
test-${target}
PROPERTY
ENVIRONMENT "GOPATH=${gopath}")
WORKING_DIRECTORY ${source_dir})
message(STATUS "Added test 'test-${target}'")
endif ()
endfunction()
......@@ -19,4 +19,4 @@ define_property(TARGET PROPERTY EXENAME
set_target_properties(${TARGET_NAME} PROPERTIES EXENAME ${CMAKE_CURRENT_BINARY_DIR}/${exe_name})
gotest(${TARGET_NAME} "${CMAKE_CURRENT_SOURCE_DIR}" "./...")
gotest(${TARGET_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/src/asapo_tools" "./...")
......@@ -15,8 +15,8 @@ var tokenTests = []struct {
msg string
}{
{command{args: []string{"beamtime_id"}}, "secret", "no secret parameter"},
{command{args: []string{"-secret","secret.tmp"}}, "beamtime id", "no file"},
{command{args: []string{"-secret","not_existing_file","beamtime_id"}}, "not_existing_file", "no file"},
{command{args: []string{"-secret","secret.tmp"}}, "payload", "no file"},
{command{args: []string{"-secret","not_existing_file","payload"}}, "not_existing_file", "no file"},
{command{args: []string{"-secret","secret.tmp","beamtime_id"}}, "eodk3s5ZXwACLGyVA63MZYcOTWuWE4bceI9Vxl9zejI=", "ok"},
}
......
......@@ -6,10 +6,7 @@ replace asapo_common v0.0.0 => ../../../common/go/src/asapo_common
require (
asapo_common v0.0.0
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/kr/pretty v0.2.0 // indirect
github.com/stretchr/testify v1.7.0
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
)
......@@ -3,8 +3,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc=
github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
......@@ -18,14 +16,11 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/sirupsen/logrus v1.8.0/go.mod h1:4GuYW9TZmE769R5STWrRakJc4UqQ3+QQ95fyz7ENv1A=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
......@@ -20,6 +20,4 @@ define_property(TARGET PROPERTY EXENAME
set_target_properties(asapo-authorizer PROPERTIES EXENAME ${CMAKE_CURRENT_BINARY_DIR}/${exe_name})
gotest(${TARGET_NAME} "${CMAKE_CURRENT_SOURCE_DIR}" "./...")
#go_integration_test(${TARGET_NAME}-connectdb "./..." "MongoDBConnect")
#go_integration_test(${TARGET_NAME}-nextrecord "./..." "MongoDBNext")
gotest(${TARGET_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/src/asapo_authorizer" "./...")
......@@ -20,6 +20,8 @@ define_property(TARGET PROPERTY EXENAME
set_target_properties(asapo-broker PROPERTIES EXENAME ${CMAKE_CURRENT_BINARY_DIR}/${exe_name})
gotest(${TARGET_NAME} "${CMAKE_CURRENT_SOURCE_DIR}" "./...")
go_integration_test(${TARGET_NAME}-connectdb "./..." "MongoDBConnect")
go_integration_test(${TARGET_NAME}-nextrecord "./..." "MongoDBNext")
gotest(${TARGET_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/src/asapo_broker" "./...")
go_integration_test(${TARGET_NAME}-connectdb "${CMAKE_CURRENT_SOURCE_DIR}/src/asapo_broker" "./..." "MongoDBConnect")
go_integration_test(${TARGET_NAME}-nextrecord "${CMAKE_CURRENT_SOURCE_DIR}/src/asapo_broker" "./..." "MongoDBNext")
......@@ -20,4 +20,4 @@ define_property(TARGET PROPERTY EXENAME
set_target_properties(asapo-file-transfer PROPERTIES EXENAME ${CMAKE_CURRENT_BINARY_DIR}/${exe_name})
gotest(${TARGET_NAME} "${CMAKE_CURRENT_SOURCE_DIR}" "./...")
gotest(${TARGET_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/src/asapo_file_transfer" "./...")
......@@ -37,7 +37,7 @@ func prepareToken(folder string) string{
var extraClaim utils.FolderTokenTokenExtraClaim
extraClaim.RootFolder = folder
claims.ExtraClaims = &extraClaim
claims.Duration = time.Duration(1) * time.Minute
claims.SetExpiration(time.Duration(1) * time.Minute)
token,_ := auth.GenerateToken(&claims)
return token
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment