@@ -11,8 +11,8 @@ import (
11
11
"github.com/stretchr/testify/assert"
12
12
)
13
13
14
- var testLicenseJsonData = "\n \" licenses\" : { \" tiers\" : [{\n \" type\" : \" Tier\" ,\n \" planName\" : \" Tier AAA\" ,\n \" grpcServiceName\" : \" ServiceA\" ,\n \" grpcMethodName\" : \" MethodA\" ,\n \" range\" : [\n {\n \" high\" : 100,\n \" fixedPriceInCogs \" : 1\n },\n {\n \" high\" : 200,\n \" fixedPriceInCogs \" : 200000 \n },\n {\n \" high\" : 300,\n \" fixedPriceInCogs \" : 100000\n }\n ],\n \" detailsUrl\" : \" http://abc.org/licenses/Tier.html\" ,\n \" isActive\" : \" true/false\" \n },\n {\n \" type\" : \" Tier\" ,\n \" planName\" : \" Tier BBB Applicable for All service.methods\" ,\n \" range\" : [\n {\n \" high\" : 100,\n \" fixedPriceInCogs \" : 1\n },\n {\n \" high\" : 200,\n \" fixedPriceInCogs \" : 200000 \n },\n {\n \" high\" : 300,\n \" fixedPriceInCogs \" : 100000\n }\n ],\n \" detailsUrl\" : \" http://abc.org/licenses/Tier.html\" ,\n \" isActive\" : \" true/false\" \n }], " +
15
- "\" subscriptions\" : {\n \" subscription\" : [\n {\n \" periodInDays\" : 30,\n \" creditsInAGI \" : 120,\n \" planName\" : \" Monthly For ServiceA/MethodA\" ,\n \" licenseCost \" : 90,\n \" grpcServiceName\" : \" ServiceA\" ,\n \" grpcMethodName\" : \" MethodA\" \n },\n {\n \" periodInDays\" : 30,\n \" creditsInAGI \" : 123,\n \" planName\" : \" Monthly\" ,\n \" licenseCost \" : 93\n },\n {\n \" periodInDays\" : 120,\n \" creditsInAGI \" : 160,\n \" licenseCost \" : 120,\n \" planName\" : \" Quarterly\" \n },\n {\n \" periodInDays\" : 365,\n \" creditsInAGI \" : 430,\n \" licenseCost \" : 390,\n \" planName\" : \" Yearly\" \n }\n ], \" type\" : \" Subscription\" ,\n \" detailsUrl\" : \" http://abc.org/licenses/Subscription.html\" ,\n \" isActive\" : \" true/false\" \n }\n }"
14
+ var testLicenseJsonData = "\n \" licenses\" : { \" tiers\" : [{\n \" type\" : \" Tier\" ,\n \" planName\" : \" Tier AAA\" ,\n \" grpcServiceName\" : \" ServiceA\" ,\n \" grpcMethodName\" : \" MethodA\" ,\n \" range\" : [\n {\n \" high\" : 100,\n \" DiscountInPercentage \" : 1\n },\n {\n \" high\" : 200,\n \" discountInPercentage \" : 20 \n },\n {\n \" high\" : 300,\n \" discountInPercentage \" : 100000\n }\n ],\n \" detailsUrl\" : \" http://abc.org/licenses/Tier.html\" ,\n \" isActive\" : \" true/false\" \n },\n {\n \" type\" : \" Tier\" ,\n \" planName\" : \" Tier BBB Applicable for All service.methods\" ,\n \" range\" : [\n {\n \" high\" : 100,\n \" discountInPercentage \" : 1\n },\n {\n \" high\" : 200,\n \" discountInPercentage \" : 200 \n },\n {\n \" high\" : 300,\n \" DiscountInPercentage \" : 100000\n }\n ],\n \" detailsUrl\" : \" http://abc.org/licenses/Tier.html\" ,\n \" isActive\" : \" true/false\" \n }], " +
15
+ "\" subscriptions\" : {\n \" subscription\" : [\n {\n \" periodInDays\" : 30,\n \" discountInPercentage \" : 120,\n \" planName\" : \" Monthly For ServiceA/MethodA\" ,\n \" LicenseCost \" : 90,\n \" grpcServiceName\" : \" ServiceA\" ,\n \" grpcMethodName\" : \" MethodA\" \n },\n {\n \" periodInDays\" : 30,\n \" discountInPercentage \" : 123,\n \" planName\" : \" Monthly\" ,\n \" LicenseCost \" : 93\n },\n {\n \" periodInDays\" : 120,\n \" discountInPercentage \" : 160,\n \" LicenseCost \" : 120,\n \" planName\" : \" Quarterly\" \n },\n {\n \" periodInDays\" : 365,\n \" discountInPercentage \" : 430,\n \" LicenseCost \" : 390,\n \" planName\" : \" Yearly\" \n }\n ], \" type\" : \" Subscription\" ,\n \" detailsUrl\" : \" http://abc.org/licenses/Subscription.html\" ,\n \" isActive\" : \" true/false\" \n }\n }"
16
16
var testJsonData = "{ \" version\" : 1, \" display_name\" : \" Example1\" , \" encoding\" : \" grpc\" , \" service_type\" : \" grpc\" , \" payment_expiration_threshold\" : 40320, \" model_ipfs_hash\" : \" Qmdiq8Hu6dYiwp712GtnbBxagyfYyvUY1HYqkH7iN76UCc\" , " +
17
17
" \" mpe_address\" : \" 0x7E6366Fbe3bdfCE3C906667911FC5237Cc96BD08\" , \" groups\" : [ { \" free_calls\" : 12, \" free_call_signer_address\" : \" 0x7DF35C98f41F3Af0df1dc4c7F7D4C19a71Dd059F\" , \" endpoints\" : [\" http://34.344.33.1:2379\" ,\" http://34.344.33.1:2389\" ], \" group_id\" : \" 88ybRIg2wAx55mqVsA6sB4S7WxPQHNKqa4BPu/bhj+U=\" ,\" group_name\" : \" default_group\" , " + testLicenseJsonData + " , \" pricing\" : [ { \" price_model\" : \" fixed_price\" , \" price_in_cogs\" : 2 }, { \" package_name\" : \" example_service\" , \" price_model\" : \" fixed_price_per_method\" , \" default\" :true, \" details\" : [ { \" service_name\" : \" Calculator\" , \" method_pricing\" : [ { \" method_name\" : \" add\" , \" price_in_cogs\" : 2 }, { \" method_name\" : \" sub\" , \" price_in_cogs\" : 1 }, { \" method_name\" : \" div\" , \" price_in_cogs\" : 2 }, { \" method_name\" : \" mul\" , \" price_in_cogs\" : 3 } ] }, { \" service_name\" : \" Calculator2\" , \" method_pricing\" : [ { \" method_name\" : \" add\" , \" price_in_cogs\" : 2 }, { \" method_name\" : \" sub\" , \" price_in_cogs\" : 1 }, { \" method_name\" : \" div\" , \" price_in_cogs\" : 3 }, { \" method_name\" : \" mul\" , \" price_in_cogs\" : 2 } ] } ] }] }, { \" endpoints\" : [\" http://97.344.33.1:2379\" ,\" http://67.344.33.1:2389\" ], \" group_id\" : \" 99ybRIg2wAx55mqVsA6sB4S7WxPQHNKqa4BPu/bhj+U=\" , \" pricing\" : [ { \" package_name\" : \" example_service\" , \" price_model\" : \" fixed_price_per_method\" , \" details\" : [ { \" service_name\" : \" Calculator\" , \" method_pricing\" : [ { \" method_name\" : \" add\" , \" price_in_cogs\" : 2 }, { \" method_name\" : \" sub\" , \" price_in_cogs\" : 1 }, { \" method_name\" : \" div\" , \" price_in_cogs\" : 2 }, { \" method_name\" : \" mul\" , \" price_in_cogs\" : 3 } ] }, { \" service_name\" : \" Calculator2\" , \" method_pricing\" : [ { \" method_name\" : \" add\" , \" price_in_cogs\" : 2 }, { \" method_name\" : \" sub\" , \" price_in_cogs\" : 1 }, { \" method_name\" : \" div\" , \" price_in_cogs\" : 3 }, { \" method_name\" : \" mul\" , \" price_in_cogs\" : 2 } ] } ] }] } ] } "
18
18
@@ -45,6 +45,7 @@ func TestSubscription(t *testing.T) {
45
45
assert .Equal (t , metaData .GetLicenses ().Subscriptions .Subscription [0 ].PlanName , "Monthly For ServiceA/MethodA" )
46
46
assert .Equal (t , metaData .GetLicenses ().Subscriptions .Subscription [0 ].GrpcMethodName , "MethodA" )
47
47
assert .Equal (t , metaData .GetLicenses ().Subscriptions .Subscription [0 ].GrpcServiceName , "ServiceA" )
48
+ assert .Equal (t , metaData .GetLicenses ().Subscriptions .Subscription [0 ].DiscountInPercentage , 120 )
48
49
}
49
50
50
51
func TestTiers (t * testing.T ) {
@@ -54,6 +55,7 @@ func TestTiers(t *testing.T) {
54
55
55
56
assert .Equal (t , metaData .GetLicenses ().Tiers [0 ].Type , "Tier" )
56
57
assert .Equal (t , metaData .GetLicenses ().Tiers [0 ].Range [0 ].High , 100 )
58
+ assert .Equal (t , metaData .GetLicenses ().Tiers [0 ].Range [0 ].DiscountInPercentage , 1 )
57
59
}
58
60
func TestInitServiceMetaDataFromJson (t * testing.T ) {
59
61
//Parse Bad JSON
0 commit comments