xml input: add basic unit test case (#4894)

This commit is contained in:
Lars Hvam 2021-08-25 08:11:02 +02:00 committed by GitHub
parent 21cee10b3b
commit 40fa13278d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 11 deletions

View File

@ -1,6 +1,6 @@
name: test name: test
on: on:
push: push:
pull_request: pull_request:
types: [opened] types: [opened]
@ -8,6 +8,7 @@ on:
jobs: jobs:
unit: unit:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 5
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2
@ -18,6 +19,7 @@ jobs:
integration: integration:
needs: unit needs: unit
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 5
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2

View File

@ -18,9 +18,9 @@
"url": "git+https://github.com/abapGit/abapGit.git" "url": "git+https://github.com/abapGit/abapGit.git"
}, },
"devDependencies": { "devDependencies": {
"@abaplint/cli": "^2.76.8", "@abaplint/cli": "^2.76.13",
"@abaplint/transpiler-cli": "^1.6.4", "@abaplint/transpiler-cli": "^1.6.10",
"@abaplint/runtime": "^1.6.4", "@abaplint/runtime": "^1.6.10",
"abapmerge": "^0.14.3", "abapmerge": "^0.14.3",
"eslint": "^7.32.0" "eslint": "^7.32.0"
} }

View File

@ -2,12 +2,10 @@ CLASS ltcl_xml DEFINITION FOR TESTING DURATION SHORT RISK LEVEL HARMLESS.
PUBLIC SECTION. PUBLIC SECTION.
METHODS: METHODS:
up FOR TESTING up FOR TESTING RAISING zcx_abapgit_exception,
RAISING zcx_abapgit_exception, empty FOR TESTING RAISING zcx_abapgit_exception,
empty FOR TESTING input FOR TESTING RAISING zcx_abapgit_exception,
RAISING zcx_abapgit_exception, down FOR TESTING RAISING zcx_abapgit_exception.
down FOR TESTING
RAISING zcx_abapgit_exception.
TYPES: BEGIN OF ty_old, TYPES: BEGIN OF ty_old,
foo TYPE i, foo TYPE i,
@ -25,6 +23,36 @@ ENDCLASS.
CLASS ltcl_xml IMPLEMENTATION. CLASS ltcl_xml IMPLEMENTATION.
METHOD input.
DATA lv_xml TYPE string.
DATA lo_input TYPE REF TO zcl_abapgit_xml_input.
DATA ls_data TYPE ty_old.
lv_xml = |<?xml version="1.0" encoding="utf-16"?>\n| &&
|<abapGit version="v1.0.0">\n| &&
| <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">\n| &&
| <asx:values>\n| &&
| <DATA>\n| &&
| <FOO>2</FOO>\n| &&
| </DATA>\n| &&
| </asx:values>\n| &&
| </asx:abap>\n| &&
|</abapGit>|.
CREATE OBJECT lo_input
EXPORTING
iv_xml = lv_xml.
lo_input->zif_abapgit_xml_input~read( EXPORTING iv_name = 'DATA'
CHANGING cg_data = ls_data ).
cl_abap_unit_assert=>assert_equals(
act = ls_data-foo
exp = 2 ).
ENDMETHOD.
METHOD empty. METHOD empty.
DATA: ls_old TYPE ty_old, DATA: ls_old TYPE ty_old,
@ -124,4 +152,4 @@ CLASS ltcl_xml IMPLEMENTATION.
ENDMETHOD. ENDMETHOD.
ENDCLASS. ENDCLASS.