Skip to content

Commit c25d3e2

Browse files
committed
Remove the unused record file and add SET_RECORD_FILE_ATTR_ON_READ to detect which records have been used.
1 parent ac39251 commit c25d3e2

File tree

2 files changed

+13
-1590
lines changed

2 files changed

+13
-1590
lines changed

dd-java-agent/instrumentation/openai-java/openai-java-3.0/src/test/java/RequestResponseRecord.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@
88
import java.nio.charset.StandardCharsets;
99
import java.nio.file.Files;
1010
import java.nio.file.Path;
11+
import java.nio.file.attribute.PosixFilePermissions;
1112
import java.security.MessageDigest;
1213
import java.util.List;
1314
import java.util.Map;
1415

1516
public class RequestResponseRecord {
16-
public static final String RECORD_FILE_HASH_ALG = "MD5";
17-
17+
/**
18+
* Turn it on when the tests change to identify which records have been used and which can be
19+
* removed. This sets the execution attribute of the record file, so Git recognizes the file as
20+
* changed. This is useful for identifying unused records when changing tests.
21+
*/
22+
public static final boolean SET_RECORD_FILE_ATTR_ON_READ = false;
23+
24+
private static final String RECORD_FILE_HASH_ALG = "MD5";
1825
private static final String METHOD = "method: ";
1926
private static final String PATH = "path: ";
2027
private static final String BEGIN_REQUEST_BODY = "-- begin request body --";
@@ -171,6 +178,10 @@ public static RequestResponseRecord read(Path recFilePath) {
171178
bodyBuilder.append(line);
172179
}
173180
}
181+
182+
if (SET_RECORD_FILE_ATTR_ON_READ) {
183+
Files.setPosixFilePermissions(recFilePath, PosixFilePermissions.fromString("rwxr-xr-x"));
184+
}
174185
} catch (IOException e) {
175186
throw new RuntimeException(e);
176187
}

0 commit comments

Comments
 (0)