...

Source file src/go.mongodb.org/mongo-driver/internal/spectest/spectest.go

Documentation: go.mongodb.org/mongo-driver/internal/spectest

     1  // Copyright (C) MongoDB, Inc. 2023-present.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License"); you may
     4  // not use this file except in compliance with the License. You may obtain
     5  // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
     6  
     7  package spectest
     8  
     9  import (
    10  	"io/ioutil"
    11  	"path"
    12  	"testing"
    13  
    14  	"go.mongodb.org/mongo-driver/internal/require"
    15  )
    16  
    17  // FindJSONFilesInDir finds the JSON files in a directory.
    18  func FindJSONFilesInDir(t *testing.T, dir string) []string {
    19  	t.Helper()
    20  
    21  	files := make([]string, 0)
    22  
    23  	entries, err := ioutil.ReadDir(dir)
    24  	require.NoError(t, err)
    25  
    26  	for _, entry := range entries {
    27  		if entry.IsDir() || path.Ext(entry.Name()) != ".json" {
    28  			continue
    29  		}
    30  
    31  		files = append(files, entry.Name())
    32  	}
    33  
    34  	return files
    35  }
    36  

View as plain text