Skip to content

Commit

Permalink
- patched e2e test cases
Browse files Browse the repository at this point in the history
- removing Style logic
  • Loading branch information
adranwit committed Nov 12, 2024
1 parent 6069a01 commit 0eca65e
Show file tree
Hide file tree
Showing 36 changed files with 45 additions and 36 deletions.
4 changes: 2 additions & 2 deletions e2e/debug_gen/datly.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func main() {

baseDir := filepath.Join(toolbox.CallerDirectory(3), "..")
fmt.Printf("base: %v\n", baseDir)
caseName := "019_generate_post_comprehensive_many"
caseName := "060_tabjson_comprehensive"
caseFolder := filepath.Join(baseDir, "local/regression/cases/", caseName)
gen, err := loadGen(caseFolder, caseName)
if err != nil {
Expand All @@ -77,7 +77,7 @@ func main() {
"-N=" + gen.Name,
"-X=" + gen.URL,
"-C=dev|mysql|root:dev@tcp(127.0.0.1:3306)/dev?parseTime=true",
"-G=post",
// "-G=post",
"-C=dyndb|dynamodb|dynamodb://localhost:8000/us-west-1?key=dummy&secret=dummy",
// fmt.Sprintf("-j='%v/local/jwt/public.enc|blowfish://default'", baseDir),
"-w=autogen",
Expand Down
3 changes: 2 additions & 1 deletion e2e/local/regression/cases/001_one_to_many/vendor_list.dql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#set( $_ = $VendorName<string>(form/name).Optional().WithPredicate(0, 'contains', 't', 'NAME'))
#set( $_ = $Fields<[]string>(query/fields).Optional().QuerySelector('vendor'))
#set( $_ = $Page<int>(query/page).Optional().QuerySelector('vendor'))
#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))

#set( $_ = $Data<?>(output/view).Embed())


SELECT vendor.*,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#set( $_ = $Fields<[]string>(query/fields).Optional().QuerySelector('vendor'))
#set( $_ = $Page<int>(query/page).Optional().QuerySelector('vendor'))
#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT wrapper.* EXCEPT ID,
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/regression/cases/005_sumary/vendor_meta.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#set( $_ = $VendorName<string>(query/name).WithPredicate(0,'equal','t','id').Optional())
#set( $_ = $Meta<?>(output/summary))
#set( $_ = $Data<?>(output/view))
#set( $_ = $Status<?>(output/status).WithTag('anonymous:"true"'))
#set( $_ = $Status<?>(output/status).Embed())

SELECT vendor.*,
products.* EXCEPT VENDOR_ID
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/regression/cases/007_child_meta/child_meta.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#set( $_ = $Meta<?>(output/summary))
#set( $_ = $Data<?>(output/view))
#set( $_ = $Status<?>(output/status).WithTag('anonymous:"true"'))
#set( $_ = $Status<?>(output/status).Embed())

SELECT vendor.*,
products.* EXCEPT VENDOR_ID,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* {"URI":"meta/districts"} */

#set( $_ = $Page<int>(query/page).Optional().QuerySelector('districts'))
#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT districts.*,
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/regression/cases/009_apikey/vendor_apikey.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
} */

#set( $_ = $Page<int>(query/page).Optional().QuerySelector('vendor'))
#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT vendor.*,
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/regression/cases/010_codecs/vendors_codec.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* {"URI":"vendors-codec/"} */

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())

SELECT vendor.*
FROM (SELECT * FROM VENDOR t WHERE t.ID IN ($vendorIDs) ) vendor
2 changes: 1 addition & 1 deletion e2e/local/regression/cases/011_env/environment.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* { "URI":"vendors-env/", "Const": { "Vendor": "VENDOR", "Product": "PRODUCT" } } */

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())

SELECT vendor.*,
products.*
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/regression/cases/012_meta_format/meta_format.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#set( $_ = $Meta<?>(output/summary))
#set( $_ = $Data<?>(output/view))
#set( $_ = $Status<?>(output/status).WithTag('anonymous:"true"'))
#set( $_ = $Status<?>(output/status).Embed())

SELECT vendor.*,
products.* EXCEPT VENDOR_ID,
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/regression/cases/013_col_in/vendor_col_in.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
} */

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT vendor.*,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* {"URI":"headers/vendors"} */

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())

SELECT vendor.*,
products.* EXCEPT VENDOR_ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#set( $_ = $Fields<[]string>(query/fields).Optional().QuerySelector('user_metadata'))
#set( $_ = $Page<int>(query/page).Optional().QuerySelector('user_metadata'))

#set( $_ = $UserMetadata<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $UserMetadata<?>(output/view).Embed())


SELECT user_metadata.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (


#set($_ = $Data<*Events>(body/Data).Output())
#set($_ = $Status<?>(output/status).WithTag('anonymous:"true"'))
#set($_ = $Status<?>(output/status).Embed())

#set($_ = $Events<*Events>(body/Data))
#set($_ = $Jwt<string>(Header/Authorization).WithCodec(JwtClaim).WithStatusCode(401))
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/regression/cases/042_json_codec/json_codec.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"regression/cases/042_json_codec.Record"
)

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT main.*,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"regression/cases/043_json_codec_single.Record"
)

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT main.* EXCEPT(Id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"regression/cases/044_inline_json_codec.Record"
)

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT main.*,
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/regression/cases/045_raw_json/raw_json.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"regression/cases/045_raw_json.Record"
)

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT main.*,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* {"URI":"raw_json_tag"} */

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT main.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* {"URI":"raw_json_expr"} */

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT main.*,
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/regression/cases/049_oauth_hmac/vendor_hauth.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* {"URI":"hauth/vendors/{vendorID}"} */


#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())
#set($_ = $Jwt<string>(Header/Authorization).WithCodec(JwtClaim).WithStatusCode(401))
#set($_ = $Authorization /*
!!403 SELECT Authorized /* {"DataType":"bool"} */
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/regression/cases/055_variables/vars.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}
*/

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT main.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* {"URI":"tabular/basic/vendors/", "DataFormat":"tabular", "TabularJSON":{"FloatPrecision":"20"}} */

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())

SELECT vendor.* EXCEPT CREATED,UPDATED,
products.* EXCEPT VENDOR_ID,CREATED,UPDATED
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/regression/cases/059_tabjson_basic/bar_list.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* {"URI":"basic/bars/", "DataFormat":"tabular", "TabularJSON":{"FloatPrecision":"8"}} */

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())

SELECT bar.*
FROM (SELECT * FROM BAR t ) bar
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* {"URI":"comprehensive/bars/", "DataFormat":"tabular", "TabularJSON":{"FloatPrecision":"-1"}} */


#set( $_ = $Data<?>(output/view).Cardinality('One').WithTag('anonymous:"true"'))

#set( $_ = $Data<?>(output/view).Cardinality('Many'))

SELECT bar.*
FROM (SELECT * FROM BAR t ) bar
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#set($_ = $UserCreated<int>(query/UserCreated).WithPredicate(0, "equal", "t", "USER_CREATED").Optional())
#set($_ = $Name<string>(query/Name).WithPredicate(1, "equal", "t", "NAME").Optional())
#set($_ = $AccountID<int>(query/AccountID).WithPredicate(1, "equal", "t", "ACCOUNT_ID").Optional())
#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT vendor.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
} */


#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT vendor.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#set($_ = $IDMin<int>(query/idMin).Of('IDRange').WithTag('velty:"names=IDMin|ValueMin"').Optional())
#set($_ = $IDMax<int>(query/idMax).Of('IDRange').WithTag('velty:"names=IDMax|ValueMax"').Optional())

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT bar.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

#set($_ = $IDs<[]string>(query/ids).WithCodec("Encode", "*VendorIds", "/" , "ID", "AccountID", "UserCreated").WithPredicate(0, "multi_in", "t"))
#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())

SELECT vendor.*
FROM (
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/regression/cases/066_xls_output/vendor_xls.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* {"URI":"vendors/xls/", "DataFormat":"xls"} */

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT vendor.*,
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/regression/cases/067_xml_basic/xml_bar_list.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* {"URI":"xml/basic/bars/", "DataFormat":"xml", "XML":{"FloatPrecision":"8"}} */


#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT bar.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* {"URI":"xml/basic/vendors/", "DataFormat":"xml", "XML":{"FloatPrecision":"20"}} */

#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())


SELECT vendor.* EXCEPT CREATED,UPDATED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

#set($_ = $IDs<[]string>(query/ids).WithCodec("Encode", "*encode_struct_pkg.VendorIds", "/" , "ID", "AccountID", "UserCreated").WithPredicate(0, "multi_in", "t"))
#set( $_ = $Data<?>(output/view).WithTag('anonymous:"true"'))
#set( $_ = $Data<?>(output/view).Embed())

SELECT vendor.*
FROM (
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/regression/regression.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pipeline:
'[]gen': '@gen'

subPath: 'cases/${index}_*'
range: 1..069
range: 60..060
template:
checkSkip:
action: nop
Expand Down
7 changes: 7 additions & 0 deletions internal/translator/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ func (s *Service) detectComponentViewType(viewColumns discover.Columns, resource
if root.View.View.Schema == nil {
root.View.View.Schema = &state.Schema{Cardinality: state.Many}
}

if dataParameter := resource.OutputState.Parameters().LookupByLocation(state.KindOutput, "view"); dataParameter != nil {
if dataParameter.Schema != nil && dataParameter.Schema.Cardinality != "" {
root.View.Schema.Cardinality = dataParameter.Schema.Cardinality
}
}

if root.View.Schema.Cardinality == "" {
root.View.Schema.Cardinality = state.Many
}
Expand Down
2 changes: 2 additions & 0 deletions internal/translator/parser/declarations.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ func (s *Declarations) parseShorthands(declaration *Declaration, cursor *parsly.
content = content[1 : len(content)-1]
args := extractArgs(content)
switch text {
case "Embed":
declaration.Tag += ` anonymous:"true"`
case "WithTag", "Tag":
if len(args) != 1 {
return fmt.Errorf("expected WithTag to have one args, but got %v", len(args))
Expand Down

0 comments on commit 0eca65e

Please sign in to comment.