github.com/web-platform-tests/wpt.fyi@v0.0.0-20240530210107-70cf978996f1/api/manifest/util_test.go (about)

     1  //go:build small
     2  // +build small
     3  
     4  // Copyright 2017 The WPT Dashboard Project. All rights reserved.
     5  // Use of this source code is governed by a BSD-style license that can be
     6  // found in the LICENSE file.
     7  
     8  package manifest
     9  
    10  import (
    11  	"testing"
    12  
    13  	"github.com/stretchr/testify/assert"
    14  )
    15  
    16  func TestFilter(t *testing.T) {
    17  	// This is a smoke test; see shared/manifest_test.go for more tests.
    18  	bytes := []byte(`{
    19  "items": {
    20  	"testharness": {
    21  		"foo": {
    22  			"bar": {
    23  				"test.html": [
    24  					"1d3166465cc6f2e8f9f18f53e499ca61e12d59bd",
    25  					[null, {}]
    26  				]
    27  
    28  			}
    29  		},
    30  		"foobar": {
    31  			"mytest.html": [
    32  				"2d3166465cc6f2e8f9f18f53e499ca61e12d59bd",
    33  				[null, {}]
    34  			]
    35  		}
    36  	},
    37  	"manual": {
    38  		"foobar": {
    39  			"test-manual.html": [
    40  				"3d3166465cc6f2e8f9f18f53e499ca61e12d59bd",
    41  				[null, {}]
    42  			]
    43  		}
    44  	}
    45  },
    46  "version": 8
    47  }`)
    48  
    49  	filtered, err := Filter(bytes, []string{"/foo/bar"})
    50  	assert.Nil(t, err)
    51  	assert.Equal(t, `{"items":{"testharness":{"foo":{"bar":{"test.html":["1d3166465cc6f2e8f9f18f53e499ca61e12d59bd",[null,{}]]}}}},"version":8}`, string(filtered))
    52  }