Skip to content

Conversation

@llimllib
Copy link

@llimllib llimllib commented Jun 16, 2023

a whack at fixing #312

To test this, I:

  • generated all new fixtures with OVERWRITE_EVERYTHING=true npm run test
  • generated a C# hello world project with dotnet new console -o HelloWorld -f net7.0
  • installed RestSharp into it with dotnet add package RestSharp]
  • ran this script and looked for significant differences between csharp and bash:
#!/usr/bin/env bash
set -euxo pipefail
file=Program.cs
mkdir -p fixtures
# for the multipart tests
printf "hello" > hello.txt
for fixture in ~/readme/kong-httpsnippet/src/targets/csharp/restsharp/fixtures/*; do
    rm -f $file

    # the custom method isn't supported
    if [[ $fixture == *custom-method* ]]; then continue; fi

    printf "using RestSharp;\n\n" > $file
    sed 's,test/fixtures/files/hello.txt,hello.txt,' "$fixture" >> $file
    printf 'Console.WriteLine("{0}", response.Content);' >> $file

    dotnet run $file > "fixtures/$(basename "$fixture".out)"
done
#
# now run the bash fixtures for comparison
for fixture in ~/readme/kong-httpsnippet/src/targets/shell/curl/fixtures/*; do
    # the curl for custom-indentation does not work properly, so we need to add
    # || true
    sed 's,test/fixtures/files/hello.txt,hello.txt,' "$fixture" |
        bash > "fixtures/$(basename "$fixture".out)" || true
done

# then, compare the outputs
for fixture in ~/readme/kong-httpsnippet/kong-httpsnippet/src/targets/http/http1.1/fixtures/*; do
    base=$(basename "$fixture")
    cs="fixtures/$base.cs.out"
    sh="fixtures/$base.sh.out"

    if [[ ! -e $cs ]]; then printf "Unable to find fixture %s\n" "$cs"; continue; fi
    if [[ ! -e $cs ]]; then printf "Unable to find fixture %s\n" "$sh"; continue; fi

    git diff "fixtures/$base.cs.out" "fixtures/$base.sh.out" || true
done

@llimllib
Copy link
Author

llimllib commented Jul 10, 2023

Closing here, fixed in readmeio/httpsnippet, here

@llimllib llimllib closed this Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant