about summary refs log tree commit diff
path: root/lib/fileset/tests.sh
diff options
context:
space:
mode:
authorSilvan Mosberger <silvan.mosberger@tweag.io>2023-09-13 18:50:45 +0200
committerSilvan Mosberger <silvan.mosberger@tweag.io>2023-09-13 18:53:53 +0200
commit19b39dcc934aba37e39b5f492c2919dd93b74870 (patch)
tree35184a186a01641a4ee0ec6e9acda5d043e1b721 /lib/fileset/tests.sh
parent48abfde844547c1b62c8a082ccccd9caf2d650bd (diff)
lib.fileset: Internal representation v1
Diffstat (limited to 'lib/fileset/tests.sh')
-rwxr-xr-xlib/fileset/tests.sh12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/fileset/tests.sh b/lib/fileset/tests.sh
index 88cd4bcc47c9c..e27610573a86e 100755
--- a/lib/fileset/tests.sh
+++ b/lib/fileset/tests.sh
@@ -264,17 +264,21 @@ expectFailure 'toSource { root = ./.; fileset = ./a; }' 'lib.fileset.toSource: `
 # File sets cannot be evaluated directly
 expectFailure '_create ./. null' 'lib.fileset: Directly evaluating a file set is not supported. Use `lib.fileset.toSource` to turn it into a usable source instead.'
 
+# Past versions of the internal representation are supported
+expectEqual '_coerce "<tests>: value" { _type = "fileset"; _internalVersion = 0; _internalBase = ./.; }' \
+    '{ _internalBase = ./.; _internalBaseComponents = path.subpath.components (path.splitRoot ./.).subpath; _internalBaseRoot = /.; _internalVersion = 1; _type = "fileset"; }'
+
 # Future versions of the internal representation are unsupported
-expectFailure '_coerce "<tests>: value" { _type = "fileset"; _internalVersion = 1; }' '<tests>: value is a file set created from a future version of the file set library with a different internal representation:
-\s*- Internal version of the file set: 1
-\s*- Internal version of the library: 0
+expectFailure '_coerce "<tests>: value" { _type = "fileset"; _internalVersion = 2; }' '<tests>: value is a file set created from a future version of the file set library with a different internal representation:
+\s*- Internal version of the file set: 2
+\s*- Internal version of the library: 1
 \s*Make sure to update your Nixpkgs to have a newer version of `lib.fileset`.'
 
 # _create followed by _coerce should give the inputs back without any validation
 expectEqual '{
   inherit (_coerce "<test>" (_create ./. "directory"))
     _internalVersion _internalBase _internalTree;
-}' '{ _internalBase = ./.; _internalTree = "directory"; _internalVersion = 0; }'
+}' '{ _internalBase = ./.; _internalTree = "directory"; _internalVersion = 1; }'
 
 #### Resulting store path ####