Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
fix(go-client): handle empty secret env interpolation (#4013)
Browse files Browse the repository at this point in the history
  • Loading branch information
Divyendu Singh authored and timsuchanek committed Feb 7, 2019
1 parent e4f50c8 commit ff6ae93
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Generated by [AVA](https://ava.li).
var DefaultEndpoint = http://localhost:4466/test/test␊
var Secret = ␊
var Secret = ""
type PostsParams struct {␊
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ The actual snapshot is saved in `go-env.test.js.snap`.

Generated by [AVA](https://ava.li).

## go env interpolation - empty

> Snapshot 1
'""'

## go env interpolation - environment multiple

> Snapshot 1
Expand All @@ -16,6 +22,12 @@ Generated by [AVA](https://ava.li).
'os.Getenv("PRISMA_ENDPOINT")'

## go env interpolation - null

> Snapshot 1
'""'

## go env interpolation - plain

> Snapshot 1
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { GoGenerator } from '../../go-client'
import { test } from 'ava'

test('go env interpolation - empty', t => {
const result = GoGenerator.replaceEnv(``)
t.snapshot(result)
})

test('go env interpolation - null', t => {
const result = GoGenerator.replaceEnv(null as any)
t.snapshot(result)
})

test('go env interpolation - plain', t => {
const result = GoGenerator.replaceEnv(`http://localhost:4466/test/dev`)
t.snapshot(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ func (client *Client) GraphQL(ctx context.Context, query string, variables map[s
const dynamic = `
var DefaultEndpoint = ${options.endpoint}
var Secret = ${options.secret || ''}
var Secret = ${options.secret || `""`}
${this.printOperation(queryFields, 'query', options)}
Expand Down

0 comments on commit ff6ae93

Please sign in to comment.