File: main_test.go

package info (click to toggle)
golang-github-alecthomas-participle-v2 2.1.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 920 kB
  • sloc: javascript: 1,164; sh: 41; makefile: 7
file content (24 lines) | stat: -rw-r--r-- 560 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package main

import (
	"encoding/json"
	"os"
	"testing"

	require "github.com/alecthomas/assert/v2"
)

func TestExe(t *testing.T) {
	r, err := os.Open("github-webhook.json")
	require.NoError(t, err)
	input := map[string]interface{}{}
	err = json.NewDecoder(r).Decode(&input)
	require.NoError(t, err)

	ast, err := parser.ParseString(``, `check_run.check_suite.pull_requests[0].url`)
	require.NoError(t, err)

	result, err := match(input, ast)
	require.NoError(t, err)
	require.Equal(t, "https://api.github.com/repos/Codertocat/Hello-World/pulls/2", result)
}