github.com/drone/runner-go@v1.12.0/manifest/parse_test.go (about)

     1  // Copyright 2019 Drone.IO Inc. All rights reserved.
     2  // Use of this source code is governed by the Polyform License
     3  // that can be found in the LICENSE file.
     4  
     5  package manifest
     6  
     7  import (
     8  	"encoding/json"
     9  	"io/ioutil"
    10  
    11  	"github.com/google/go-cmp/cmp"
    12  )
    13  
    14  func diff(file string) (string, error) {
    15  	a, err := ParseFile(file)
    16  	if err != nil {
    17  		return "", err
    18  	}
    19  	d, err := ioutil.ReadFile(file + ".golden")
    20  	if err != nil {
    21  		return "", err
    22  	}
    23  	b := new(Manifest)
    24  	err = json.Unmarshal(d, b)
    25  	if err != nil {
    26  		return "", err
    27  	}
    28  	return cmp.Diff(a, b), nil
    29  }